]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
New app testing active scan in nonbeacon-enabled mode, written by Jasper Buesch
authorjanhauer <janhauer>
Wed, 10 Jun 2009 09:38:41 +0000 (09:38 +0000)
committerjanhauer <janhauer>
Wed, 10 Jun 2009 09:38:41 +0000 (09:38 +0000)
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/README.txt [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/app_profile.h [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/Makefile [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordAppC.nc [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordC.nc [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/Makefile [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceAppC.nc [new file with mode: 0644]
apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceC.nc [new file with mode: 0644]

diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/README.txt b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/README.txt
new file mode 100644 (file)
index 0000000..588b609
--- /dev/null
@@ -0,0 +1,48 @@
+README for TestActiveScan
+Author/Contact: tinyos-help@millennium.berkeley.edu
+
+Description:
+
+In this application one node takes the role of a PAN coordinator in a
+nonbeacon-enabled 802.15.4 PAN; it switches its radio to receive mode.
+
+A second node acts as a device; it switches to the pre-defined channel and
+performs active-scans on the predefined channel. 
+
+A few basic parameters of this example can be adjusted through the
+'app_profile.h' file.
+
+Leds Coordinator: The first led (Telos: red) is used for debugging purposes
+only and when switched on indicating an error in the protocol-stack.  The
+second led (Telos: green) flashes when an active scan, more exactly a
+beacon-request, is received by the coordinator.
+
+Leds Device: The third led (Telos: blue) is activated for a second whenever an
+active-scan is performed.  Shortly after that the second or the first led
+flashes.  The second led (Telos: green), indicating that the coordinator
+defined in the 'app_profile.h' where found in that scan.  The first led if
+either no devices or only no matching devices where found within the scan.
+
+Tools: NONE
+
+Usage: 
+
+1. Install the coordinator:
+
+    $ cd coordinator; make <platform> install
+
+2. Install one (or more) devices:
+
+    $ cd device; make <platform> install
+
+You can change some of the configuration parameters in app_profile.h
+
+Known bugs/limitations:
+
+- Many TinyOS 2 platforms do not have a clock that satisfies the
+  precision/accuracy requirements of the IEEE 802.15.4 standard (e.g. 
+  62.500 Hz, +-40 ppm in the 2.4 GHz band); in this case the MAC timing 
+  is not standard compliant
+
+$Id$o
+
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/app_profile.h b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/app_profile.h
new file mode 100644 (file)
index 0000000..c8e46a9
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2009, 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: Jasper Buesch <buesch@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#ifndef __APP_PROFILE_H
+#define __APP_PROFILE_H
+
+enum {
+  RADIO_CHANNEL = 26,
+  PAN_ID = 0x1234,
+  COORDINATOR_ADDRESS = 0x2345,
+  DEVICE_ADDRESS = 0x2346
+};
+
+#endif
+
+
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/Makefile b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/Makefile
new file mode 100644 (file)
index 0000000..8558fc7
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestActiveScanCoordAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../../Makefile.include
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordAppC.nc b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordAppC.nc
new file mode 100644 (file)
index 0000000..a1c07f5
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009, 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: Jasper Buesch <buesch@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+configuration TestActiveScanCoordAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154NonBeaconEnabledC as MAC;
+  components new Timer62500C() as Timer1;
+  components TestActiveScanCoordC as App;
+
+  MainC.Boot <- App;
+  App.MLME_RESET -> MAC;
+  App.MLME_SET -> MAC;
+  App.MLME_GET -> MAC;
+  App.MLME_START -> MAC;
+  App.IEEE154TxBeaconPayload -> MAC;
+
+  App.Led1Timer -> Timer1;
+  App.Leds -> LedsC;
+}
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordC.nc b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/coordinator/TestActiveScanCoordC.nc
new file mode 100644 (file)
index 0000000..515a441
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2009, 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: Jasper Buesch <buesch@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154.h"
+#include "app_profile.h"
+module TestActiveScanCoordC
+{
+  uses {
+    interface Boot;
+    interface MLME_RESET;
+    interface MLME_START;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface IEEE154TxBeaconPayload;
+    interface Leds;
+    interface Timer<T62500hz> as Led1Timer;
+
+  }
+} implementation {
+
+  event void Boot.booted() {
+    call MLME_RESET.request(TRUE);
+  }
+
+  event void MLME_RESET.confirm(ieee154_status_t status) {
+    if (status != IEEE154_SUCCESS) 
+      return;
+    call MLME_SET.macShortAddress(COORDINATOR_ADDRESS);
+    call MLME_SET.macAssociationPermit(FALSE);
+    call MLME_SET.macRxOnWhenIdle(TRUE);
+    call MLME_START.request(
+                          PAN_ID,           // PANId
+                          RADIO_CHANNEL,    // LogicalChannel
+                          0,                // ChannelPage,
+                          0,                // StartTime,
+                          15,               // BeaconOrder
+                          15,               // SuperframeOrder
+                          TRUE,             // PANCoordinator
+                          FALSE,            // BatteryLifeExtension
+                          FALSE,            // CoordRealignment
+                          NULL,             // no realignment security
+                          NULL              // no beacon security
+                        );    
+  }
+
+  event void MLME_START.confirm(ieee154_status_t status) {}
+
+  event void IEEE154TxBeaconPayload.aboutToTransmit() {
+    call Leds.led1On();
+    call Led1Timer.startOneShot(62500U);
+  }
+
+  event void Led1Timer.fired(){
+    call Leds.led1Off();
+  }
+
+  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(){}
+}
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/Makefile b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/Makefile
new file mode 100644 (file)
index 0000000..1f7a2be
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestActiveScanDeviceAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../../Makefile.include
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceAppC.nc b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceAppC.nc
new file mode 100644 (file)
index 0000000..941bbc4
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2009, 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: Jasper Buesch <buesch@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+configuration TestActiveScanDeviceAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154NonBeaconEnabledC as MAC,
+             new Timer62500C() as Timer1, 
+             new Timer62500C() as Timer2, 
+             new Timer62500C() as Timer3, 
+             new Timer62500C() as Timer4;
+  components TestActiveScanDeviceC as App;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> MAC;
+  App.MLME_SET -> MAC;
+  App.MLME_GET -> MAC;
+  App.MLME_SCAN -> MAC;
+
+  App.ScanTimer -> Timer1;
+  App.Led0Timer -> Timer2;
+  App.Led1Timer -> Timer3;
+  App.Led2Timer -> Timer4;
+
+
+}
diff --git a/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceC.nc b/apps/tests/tkn154/nonbeacon-enabled/TestActiveScan/device/TestActiveScanDeviceC.nc
new file mode 100644 (file)
index 0000000..e1534ed
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2009, 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: Jasper Buesch <buesch@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+#include "TKN154.h"
+#include "app_profile.h"
+module TestActiveScanDeviceC
+{
+  uses {
+    interface Boot;
+    interface MLME_RESET;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface MLME_SCAN;
+    interface Leds;
+    interface Timer<T62500hz> as ScanTimer;
+    interface Timer<T62500hz> as Led1Timer;
+    interface Timer<T62500hz> as Led0Timer;
+    interface Timer<T62500hz> as Led2Timer;
+  }
+} implementation {
+
+  ieee154_PANDescriptor_t m_PANDescriptor[5];
+
+  event void Boot.booted() {
+    call MLME_RESET.request(TRUE);
+  }
+
+  event void MLME_RESET.confirm(ieee154_status_t status) {
+    if (status == IEEE154_SUCCESS){
+    call ScanTimer.startPeriodic(125000U); 
+    }
+  }
+
+  event void ScanTimer.fired() {
+    ieee154_phyChannelsSupported_t channelMask;
+    channelMask = ((uint32_t) 1) << RADIO_CHANNEL;
+    call Leds.led2On();
+    call Led2Timer.startOneShot(62500U);
+    call MLME_SCAN.request  (
+                           ACTIVE_SCAN,            // ScanType
+                           channelMask,            // ScanChannels
+                           5,                      // ScanDuration
+                           0x00,                   // ChannelPage
+                           0,                      // EnergyDetectListNumEntries
+                           NULL,                   // EnergyDetectList
+                           5,                      // PANDescriptorListNumEntries
+                           m_PANDescriptor,        // PANDescriptorList
+                           0                       // security
+                        );
+  }
+
+  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
+                        ){
+    uint8_t scanIndex;
+    uint8_t rightCoordFound = FALSE;
+
+    for(scanIndex = 0; scanIndex < PANDescriptorListNumEntries; scanIndex++){
+      if( (PANDescriptorList[scanIndex].CoordAddrMode == ADDR_MODE_SHORT_ADDRESS) && 
+          (PANDescriptorList[scanIndex].CoordAddress.shortAddress == COORDINATOR_ADDRESS) &&
+          (PANDescriptorList[scanIndex].CoordPANId == PAN_ID) ) {
+        call Leds.led1On();
+        call Led1Timer.startOneShot(62500U);
+        rightCoordFound = TRUE;
+        break;
+      }
+    }
+    if(rightCoordFound == FALSE) {
+      call Leds.led0On();
+      call Led0Timer.startOneShot(62500U); 
+    }
+  }
+
+  event void Led0Timer.fired(){
+    call Leds.led0Off();
+  }
+
+  event void Led1Timer.fired(){
+    call Leds.led1Off();
+  }
+
+  event void Led2Timer.fired(){
+    call Leds.led2Off();
+  }
+
+}