]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
renaming directories to lower cases
authorjanhauer <janhauer>
Mon, 21 Jul 2008 14:56:58 +0000 (14:56 +0000)
committerjanhauer <janhauer>
Mon, 21 Jul 2008 14:56:58 +0000 (14:56 +0000)
apps/tests/tkn154/TestAssociate/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/app_profile.h [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/coordinator/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/coordinator/TestAssociateAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/coordinator/TestCoordC.nc [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/device/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/device/TestAssociateAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestAssociate/device/TestDeviceC.nc [new file with mode: 0644]

diff --git a/apps/tests/tkn154/TestAssociate/README.txt b/apps/tests/tkn154/TestAssociate/README.txt
new file mode 100644 (file)
index 0000000..eefdf41
--- /dev/null
@@ -0,0 +1,48 @@
+README for TestAssociate
+Author/Contact: tinyos-help@millennium.berkeley.edu
+
+Description:
+
+In this application one node takes the role of a PAN coordinator in a
+beacon-enabled 802.15.4 PAN; it transmits periodic beacons and waits for
+devices to request association to its PAN. Whenever a device tries to
+associate, the PAN coordinator allows association and assigns to the device a
+unique short address (starting from zero, incremented for every device
+requesting association). 
+
+A second node acts as a device; it first scans the pre-defined channel for
+beacons from the coordinator and once it finds a beacon it tries to associate
+to the PAN and synchronize to and track all future beacons. A short time after
+association the device then disassociates from the PAN. 
+
+The third LED (Telos: blue) is toggled whenever the coordinator has transmitted
+a beacon or whenever a device has received a beacon. On the coordinator the
+second LED (Telos: green) is switched on whenever an association request was
+successful and it is switched off, whenever a disassociation request was
+received. On a device the second LED is switched on while the device is
+associated to the PAN, i.e. it is switched off after disassociation. The first
+LED (Telos: red) is used for debugging, it denotes an error in the protocol
+stack and should never be on.
+
+Tools: NONE
+
+Usage: 
+
+1. Install the coordinator:
+
+    $ cd coordinator; make telosb install
+
+2. Install one (or more) devices:
+
+    $ cd device; make telosb install
+
+You can change some of the configuration parameters in app_profile.h
+
+Known bugs/limitations:
+
+- Currently this application only works on TelosB nodes
+- The MAC timing is not standard compliant, because TelosB lacks a
+  clock with sufficient precision/accuracy
+
+$Id$o
+
diff --git a/apps/tests/tkn154/TestAssociate/app_profile.h b/apps/tests/tkn154/TestAssociate/app_profile.h
new file mode 100644 (file)
index 0000000..21641f6
--- /dev/null
@@ -0,0 +1,47 @@
+/* 
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#ifndef __APP_PROFILE_H
+#define __APP_PROFILE_H
+
+enum {
+  RADIO_CHANNEL = 26,
+  PAN_ID = 0x1238,
+  COORDINATOR_ADDRESS = 0x9182,
+  BEACON_ORDER = 6,
+  SUPERFRAME_ORDER = 6,
+};
+
+#endif
diff --git a/apps/tests/tkn154/TestAssociate/coordinator/Makefile b/apps/tests/tkn154/TestAssociate/coordinator/Makefile
new file mode 100644 (file)
index 0000000..7fe7134
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestAssociateAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestAssociate/coordinator/TestAssociateAppC.nc b/apps/tests/tkn154/TestAssociate/coordinator/TestAssociateAppC.nc
new file mode 100644 (file)
index 0000000..5945ddf
--- /dev/null
@@ -0,0 +1,54 @@
+/* 
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+configuration TestAssociateAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC as Ieee802154MacC;
+  components TestCoordC as App;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+
+  App.MLME_START -> Ieee802154MacC;
+  App.MLME_ASSOCIATE -> Ieee802154MacC;
+  App.MLME_DISASSOCIATE -> Ieee802154MacC;
+  App.MLME_COMM_STATUS -> Ieee802154MacC;
+  App.Frame -> Ieee802154MacC;
+  App.IEEE154TxBeaconPayload -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestAssociate/coordinator/TestCoordC.nc b/apps/tests/tkn154/TestAssociate/coordinator/TestCoordC.nc
new file mode 100644 (file)
index 0000000..ceb793c
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without 
+ * modification, are permitted provided that the following conditions 
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright 
+ *   notice, this list of conditions and the following disclaimer in the 
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names 
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154.h"
+#include "app_profile.h"
+module TestCoordC
+{
+  uses {
+    interface Boot;
+    interface MLME_RESET;
+    interface MLME_START;
+    interface MLME_ASSOCIATE;
+    interface MLME_DISASSOCIATE;
+    interface MLME_COMM_STATUS;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface IEEE154Frame as Frame;
+    interface IEEE154TxBeaconPayload;
+    interface Leds;
+  }
+} implementation {
+
+  ieee154_address_t m_lastDevice;
+  uint16_t m_shortAddress;
+
+  event void Boot.booted() {
+    call MLME_RESET.request(TRUE, BEACON_ENABLED_PAN);
+  }
+
+  event void MLME_RESET.confirm(ieee154_status_t status)
+  {
+    if (status != IEEE154_SUCCESS)
+      return;
+    call MLME_SET.macShortAddress(COORDINATOR_ADDRESS);
+    call MLME_SET.macAssociationPermit(TRUE);
+    call MLME_START.request(
+                          PAN_ID,           // PANId
+                          RADIO_CHANNEL,    // LogicalChannel
+                          0,                // ChannelPage,
+                          0,                // StartTime,
+                          BEACON_ORDER,     // BeaconOrder
+                          SUPERFRAME_ORDER, // SuperframeOrder
+                          TRUE,             // PANCoordinator
+                          FALSE,            // BatteryLifeExtension
+                          FALSE,            // CoordRealignment
+                          0,                // no realignment security
+                          0                 // no beacon security
+                        );
+  }
+
+  event void MLME_START.confirm(ieee154_status_t status) { }
+
+  event void MLME_ASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_CapabilityInformation_t CapabilityInformation,
+                          ieee154_security_t *security
+                        )
+  {
+    call MLME_ASSOCIATE.response(DeviceAddress, m_shortAddress++, IEEE154_ASSOCIATION_SUCCESSFUL, 0);
+  }
+
+  event void MLME_DISASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          ieee154_security_t *security
+                        )
+  {
+    call Leds.led1Off();
+  }
+
+
+  event void MLME_COMM_STATUS.indication (
+                          uint16_t PANId,
+                          uint8_t SrcAddrMode,
+                          ieee154_address_t SrcAddr,
+                          uint8_t DstAddrMode,
+                          ieee154_address_t DstAddr,
+                          ieee154_status_t status,
+                          ieee154_security_t *security
+                        )
+  {
+    if (status == IEEE154_SUCCESS){
+      // association was successful
+      call Leds.led1On();
+      m_lastDevice.extendedAddress = DstAddr.extendedAddress;
+    } else {
+      call Leds.led1Off();
+    }
+  }
+
+  event void MLME_DISASSOCIATE.confirm    (
+                          ieee154_status_t status,
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress
+                        ){}
+
+  event void MLME_ASSOCIATE.confirm    (
+                          uint16_t AssocShortAddress,
+                          uint8_t status,
+                          ieee154_security_t *security
+                        ){}
+
+  event void IEEE154TxBeaconPayload.aboutToTransmit() { }
+
+  event void IEEE154TxBeaconPayload.setBeaconPayloadDone(void *beaconPayload, uint8_t length) { }
+
+  event void IEEE154TxBeaconPayload.modifyBeaconPayloadDone(uint8_t offset, void *buffer, uint8_t bufferLength) { }
+
+  event void IEEE154TxBeaconPayload.beaconTransmitted() 
+  {
+    ieee154_macBSN_t beaconSequenceNumber = call MLME_GET.macBSN();
+    if (beaconSequenceNumber & 1)
+      call Leds.led2On();
+    else
+      call Leds.led2Off();
+  }  
+}
diff --git a/apps/tests/tkn154/TestAssociate/device/Makefile b/apps/tests/tkn154/TestAssociate/device/Makefile
new file mode 100644 (file)
index 0000000..7fe7134
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestAssociateAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestAssociate/device/TestAssociateAppC.nc b/apps/tests/tkn154/TestAssociate/device/TestAssociateAppC.nc
new file mode 100644 (file)
index 0000000..c99e233
--- /dev/null
@@ -0,0 +1,58 @@
+/* 
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+configuration TestAssociateAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC as Ieee802154MacC,
+             new Timer62500C() as Timer;
+  components TestDeviceC as App;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+  App.DisassociateTimer -> Timer;  
+  App.MLME_SCAN -> Ieee802154MacC;
+  App.MLME_SYNC -> Ieee802154MacC;
+  App.MLME_BEACON_NOTIFY -> Ieee802154MacC;
+  App.MLME_SYNC_LOSS -> Ieee802154MacC;
+  App.MLME_ASSOCIATE -> Ieee802154MacC;
+  App.MLME_DISASSOCIATE -> Ieee802154MacC;
+  App.MLME_COMM_STATUS -> Ieee802154MacC;
+  App.BeaconFrame -> Ieee802154MacC;
+
+}
diff --git a/apps/tests/tkn154/TestAssociate/device/TestDeviceC.nc b/apps/tests/tkn154/TestAssociate/device/TestDeviceC.nc
new file mode 100644 (file)
index 0000000..1c22739
--- /dev/null
@@ -0,0 +1,242 @@
+/* 
+ * Copyright (c) 2008, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+#include "TKN154.h"
+#include "app_profile.h"
+module TestDeviceC
+{
+  uses {
+    interface Boot;
+    interface MLME_RESET;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface MLME_SCAN;
+    interface MLME_SYNC;
+    interface MLME_ASSOCIATE;
+    interface MLME_DISASSOCIATE;
+    interface MLME_COMM_STATUS;
+    interface MLME_BEACON_NOTIFY;
+    interface MLME_SYNC_LOSS;
+    interface Leds;
+    interface IEEE154BeaconFrame as BeaconFrame;
+    interface Timer<T62500hz> as DisassociateTimer;
+  }
+} implementation {
+
+  ieee154_CapabilityInformation_t m_capabilityInformation;
+  ieee154_PANDescriptor_t m_PANDescriptor;
+  bool m_isPANDescriptorValid;
+  void startApp();
+
+  event void Boot.booted() {
+    m_capabilityInformation.AlternatePANCoordinator = 0;
+    m_capabilityInformation.DeviceType = 0;
+    m_capabilityInformation.PowerSource = 0;
+    m_capabilityInformation.ReceiverOnWhenIdle = 0;
+    m_capabilityInformation.Reserved = 0;
+    m_capabilityInformation.SecurityCapability = 0;
+    m_capabilityInformation.AllocateAddress = 1;    
+    call MLME_RESET.request(TRUE, BEACON_ENABLED_PAN);
+  }
+
+  event void MLME_RESET.confirm(ieee154_status_t status)
+  {
+    if (status == IEEE154_SUCCESS)
+      startApp();
+  }
+
+  void startApp()
+  {
+    ieee154_phyChannelsSupported_t channel;
+    uint8_t scanDuration = BEACON_ORDER; 
+
+    m_isPANDescriptorValid = FALSE;
+
+    // scan only one channel
+    channel = ((uint32_t) 1) << RADIO_CHANNEL;
+
+    // we want all received beacons to be signalled 
+    // through the MLME_BEACON_NOTIFY interface, i.e.
+    // we set the macAutoRequest attribute to FALSE
+    call MLME_SET.macAutoRequest(FALSE);
+    m_isPANDescriptorValid = FALSE;
+    call MLME_SCAN.request  (
+                           PASSIVE_SCAN,           // ScanType
+                           channel,                // ScanChannels
+                           scanDuration,           // ScanDuration
+                           0x00,                   // ChannelPage
+                           0,                      // EnergyDetectListNumEntries
+                           NULL,                   // EnergyDetectList
+                           0,                      // PANDescriptorListNumEntries
+                           NULL,                   // PANDescriptorList
+                           NULL                    // security
+                        );
+  }
+
+  event message_t* MLME_BEACON_NOTIFY.indication (message_t* frame)
+  {
+    // received a beacon frame
+    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(
+          frame, RADIO_CHANNEL, page, &m_PANDescriptor) == SUCCESS){
+      // let's see if the beacon is from the coordinator we expect...
+      if (m_PANDescriptor.CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
+          m_PANDescriptor.CoordPANId == PAN_ID &&
+          m_PANDescriptor.CoordAddress.shortAddress == COORDINATOR_ADDRESS){
+        // yes - wait until SCAN is finished, then syncronize to beacons
+        m_isPANDescriptorValid = TRUE;
+      }
+    }
+    return frame;
+  }
+
+  event void MLME_SCAN.confirm    (
+                          ieee154_status_t status,
+                          uint8_t ScanType,
+                          uint8_t ChannelPage,
+                          uint32_t UnscannedChannels,
+                          uint8_t EnergyDetectListNumEntries,
+                          int8_t* EnergyDetectList,
+                          uint8_t PANDescriptorListNumEntries,
+                          ieee154_PANDescriptor_t* PANDescriptorList
+                        )
+  {
+    if (m_isPANDescriptorValid){
+      call MLME_SET.macPANId(m_PANDescriptor.CoordPANId);
+      call MLME_SET.macCoordShortAddress(m_PANDescriptor.CoordAddress.shortAddress);
+      call MLME_SYNC.request(m_PANDescriptor.LogicalChannel, m_PANDescriptor.ChannelPage, TRUE);
+      call MLME_ASSOCIATE.request(
+          m_PANDescriptor.LogicalChannel,
+          m_PANDescriptor.ChannelPage,
+          m_PANDescriptor.CoordAddrMode,
+          m_PANDescriptor.CoordPANId,
+          m_PANDescriptor.CoordAddress,
+          m_capabilityInformation,
+          NULL  // security
+          );
+    } else
+      startApp();
+  }
+
+  event void MLME_ASSOCIATE.confirm    (
+                          uint16_t AssocShortAddress,
+                          uint8_t status,
+                          ieee154_security_t *security
+                        )
+  {
+    if ( status == IEEE154_SUCCESS ){
+      // we are now associated - set a timer for disassociation 
+      call Leds.led1On();
+      call DisassociateTimer.startOneShot(312500U);
+    } else {
+      call MLME_ASSOCIATE.request(
+          m_PANDescriptor.LogicalChannel,
+          m_PANDescriptor.ChannelPage,
+          m_PANDescriptor.CoordAddrMode,
+          m_PANDescriptor.CoordPANId,
+          m_PANDescriptor.CoordAddress,
+          m_capabilityInformation,
+          NULL  // security
+          );
+    }
+  }
+
+  event void DisassociateTimer.fired()
+  {
+    if (call MLME_DISASSOCIATE.request  (
+        m_PANDescriptor.CoordAddrMode,
+        m_PANDescriptor.CoordPANId,
+        m_PANDescriptor.CoordAddress,
+        IEEE154_DEVICE_WISHES_TO_LEAVE,
+        FALSE,
+        NULL
+        ) != IEEE154_SUCCESS)
+      call DisassociateTimer.startOneShot(312500U);
+  }
+
+  event void MLME_DISASSOCIATE.confirm    (
+                          ieee154_status_t status,
+                          uint8_t DeviceAddrMode,
+                          uint16_t DevicePANID,
+                          ieee154_address_t DeviceAddress
+                        )
+  {
+    if (status == IEEE154_SUCCESS){
+      call Leds.led1Off();
+    } else {
+      call DisassociateTimer.startOneShot(312500U);
+    }
+  }
+
+  event void MLME_ASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_CapabilityInformation_t CapabilityInformation,
+                          ieee154_security_t *security
+                        ){}  
+
+  event void MLME_SYNC_LOSS.indication(
+                          ieee154_status_t lossReason,
+                          uint16_t PANId,
+                          uint8_t LogicalChannel,
+                          uint8_t ChannelPage,
+                          ieee154_security_t *security)
+  {
+    startApp();
+  }
+
+  event void MLME_DISASSOCIATE.indication (
+                          uint64_t DeviceAddress,
+                          ieee154_disassociation_reason_t DisassociateReason,
+                          ieee154_security_t *security
+                        ){}
+
+
+  event void MLME_COMM_STATUS.indication (
+                          uint16_t PANId,
+                          uint8_t SrcAddrMode,
+                          ieee154_address_t SrcAddr,
+                          uint8_t DstAddrMode,
+                          ieee154_address_t DstAddr,
+                          ieee154_status_t status,
+                          ieee154_security_t *security
+                        )
+  {
+  }
+}