]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
renaming directories to lower cases
authorjanhauer <janhauer>
Mon, 21 Jul 2008 15:18:16 +0000 (15:18 +0000)
committerjanhauer <janhauer>
Mon, 21 Jul 2008 15:18:16 +0000 (15:18 +0000)
30 files changed:
apps/tests/tkn154/Makefile.include
apps/tests/tkn154/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestData/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestData/app_profile.h [new file with mode: 0644]
apps/tests/tkn154/TestData/coordinator/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestData/coordinator/TestCoordReceiverC.nc [new file with mode: 0644]
apps/tests/tkn154/TestData/coordinator/TestDataAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestData/device/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestData/device/TestDataAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestData/device/TestDeviceSenderC.nc [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/app_profile.h [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/coordinator/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/coordinator/TestCoordSenderC.nc [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/coordinator/TestIndirectAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/device/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/device/TestDeviceReceiverC.nc [new file with mode: 0644]
apps/tests/tkn154/TestIndirect/device/TestIndirectAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestPromiscuous/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestPromiscuous/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestPromiscuous/TestPromiscuousAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestPromiscuous/TestPromiscuousC.nc [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/README.txt [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/app_profile.h [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/coordinator/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/coordinator/TestCoordC.nc [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/coordinator/TestStartSyncAppC.nc [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/device/Makefile [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/device/TestDeviceC.nc [new file with mode: 0644]
apps/tests/tkn154/TestStartSync/device/TestStartSyncAppC.nc [new file with mode: 0644]

index 659aaf354b2af1e0234b14e3ac87b4e856df6048..06212b52584c4e48e12a269e43633e66096ffc71 100644 (file)
@@ -18,10 +18,12 @@ include $(MAKERULES)
 # checks whether the target platform is supported by the application;
 # the application Makefile can define PLATFORMS as a whitespace-separated
 # list of supported platforms
-ifneq ($(PLATFORMS),)
-  ifeq ($(strip $(foreach platform,$(PLATFORMS),$(findstring $(platform),$(PLATFORM)))),)
-    $(error The target platform is not supported by this application - supported platforms are: $(PLATFORMS))
+ifneq ($(PLATFORM),)
+  ifneq ($(PLATFORMS),)
+    ifeq ($(strip $(foreach platform,$(PLATFORMS),$(findstring $(platform),$(PLATFORM)))),)
+      $(error The target platform is not supported by this application - supported platforms are: $(PLATFORMS))
+    endif
   endif
+  include $(TKN154_PLATFORM_INCLUDE)
 endif
 
-include $(TKN154_PLATFORM_INCLUDE)
diff --git a/apps/tests/tkn154/README.txt b/apps/tests/tkn154/README.txt
new file mode 100644 (file)
index 0000000..a515e9a
--- /dev/null
@@ -0,0 +1,14 @@
+README for tkn154 test applications
+Author/Contact: tinyos-help@millennium.berkeley.edu
+
+Description:
+
+This folder contains test applications for "TKN15.4", a platform-independent
+IEEE 802.15.4-2006 MAC implementation. Every test application resides in a
+separate subdirectory which includes a README.txt describing what it does and
+how it can be installed, respectively.
+
+The TKN15.4 implementation can be found in tinyos-2.x/tos/lib/mac/tkn154.
+
+$Id$o
+
diff --git a/apps/tests/tkn154/TestData/README.txt b/apps/tests/tkn154/TestData/README.txt
new file mode 100644 (file)
index 0000000..08d0939
--- /dev/null
@@ -0,0 +1,45 @@
+README for TestData
+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
+incoming DATA frames. 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 synchronize to and track all future beacons. It then starts to
+transmit DATA frames to the coordinator as fast as possible (direct
+transmission in the contention access period, CAP).
+
+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 toggled for every 20 received DATA frames. On a
+device the second LED is toggled for every 20 transmitted (and acknowledged)
+DATA frames. 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,X
+
+    where X is a pre-assigned short address and should be different 
+    for every device.
+
+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/TestData/app_profile.h b/apps/tests/tkn154/TestData/app_profile.h
new file mode 100644 (file)
index 0000000..bf736a0
--- /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 = 0x8172,
+  COORDINATOR_ADDRESS = 0x4331,
+  BEACON_ORDER = 5,
+  SUPERFRAME_ORDER = 5,
+};
+
+#endif
diff --git a/apps/tests/tkn154/TestData/coordinator/Makefile b/apps/tests/tkn154/TestData/coordinator/Makefile
new file mode 100644 (file)
index 0000000..42f1130
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestDataAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestData/coordinator/TestCoordReceiverC.nc b/apps/tests/tkn154/TestData/coordinator/TestCoordReceiverC.nc
new file mode 100644 (file)
index 0000000..db59ec0
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * 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 TestCoordReceiverC
+{
+  uses {
+    interface Boot;
+    interface MCPS_DATA;
+    interface MLME_RESET;
+    interface MLME_START;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface IEEE154Frame as Frame;
+    interface IEEE154TxBeaconPayload;
+    interface Leds;
+  }
+} implementation {
+
+  bool m_ledCount;
+
+  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(FALSE);
+    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,                    // CoordRealignSecurity,
+                          0                     // BeaconSecurity
+                        );
+  }
+
+  event message_t* MCPS_DATA.indication ( message_t* frame )
+  {
+    if (m_ledCount++ == 20){
+      m_ledCount = 0;
+      call Leds.led1Toggle();
+    }
+    return frame;
+  }
+
+  event void MLME_START.confirm(ieee154_status_t status) {}
+
+  event void MCPS_DATA.confirm(
+                          message_t *msg,
+                          uint8_t msduHandle,
+                          ieee154_status_t status,
+                          uint32_t Timestamp
+                        ){}
+
+  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/TestData/coordinator/TestDataAppC.nc b/apps/tests/tkn154/TestData/coordinator/TestDataAppC.nc
new file mode 100644 (file)
index 0000000..eeb8d0d
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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 TestDataAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC;
+
+  components TestCoordReceiverC as App;
+  App.MLME_START -> Ieee802154MacC;
+  App.MCPS_DATA -> Ieee802154MacC;
+  App.Frame -> Ieee802154MacC;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+  App.IEEE154TxBeaconPayload -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestData/device/Makefile b/apps/tests/tkn154/TestData/device/Makefile
new file mode 100644 (file)
index 0000000..42f1130
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestDataAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestData/device/TestDataAppC.nc b/apps/tests/tkn154/TestData/device/TestDataAppC.nc
new file mode 100644 (file)
index 0000000..f59355c
--- /dev/null
@@ -0,0 +1,56 @@
+/* 
+ * 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 TestDataAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC;
+
+  components TestDeviceSenderC as App;
+  App.MLME_SCAN -> Ieee802154MacC;
+  App.MLME_SYNC -> Ieee802154MacC;
+  App.MLME_BEACON_NOTIFY -> Ieee802154MacC;
+  App.MLME_SYNC_LOSS -> Ieee802154MacC;
+  App.MCPS_DATA -> Ieee802154MacC;
+  App.Frame -> Ieee802154MacC;
+  App.BeaconFrame -> Ieee802154MacC;
+  App.Packet -> Ieee802154MacC;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestData/device/TestDeviceSenderC.nc b/apps/tests/tkn154/TestData/device/TestDeviceSenderC.nc
new file mode 100644 (file)
index 0000000..4534df2
--- /dev/null
@@ -0,0 +1,208 @@
+/* 
+ * 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 TestDeviceSenderC
+{
+  uses {
+    interface Boot;
+    interface MCPS_DATA;
+    interface MLME_RESET;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface MLME_SCAN;
+    interface MLME_SYNC;
+    interface MLME_BEACON_NOTIFY;
+    interface MLME_SYNC_LOSS;
+    interface IEEE154Frame as Frame;
+    interface IEEE154BeaconFrame as BeaconFrame;
+    interface Leds;
+    interface Packet;
+  }
+} implementation {
+
+  message_t m_frame;
+  uint8_t m_payloadLen;
+  ieee154_PANDescriptor_t m_PANDescriptor;
+  bool m_ledCount;
+  bool m_isPANDescriptorValid;
+  bool m_sending;
+
+  void startApp();
+  task void packetSendTask();
+
+
+  event void Boot.booted() {
+    char payload[] = "Hello Coordinator!";
+    uint8_t *payloadRegion;
+
+    m_payloadLen = strlen(payload);
+    payloadRegion = call Packet.getPayload(&m_frame, m_payloadLen);
+    if (m_payloadLen <= call Packet.maxPayloadLength()){
+      memcpy(payloadRegion, payload, m_payloadLen);
+      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 channelMask;
+    uint8_t scanDuration = BEACON_ORDER;
+
+    m_isPANDescriptorValid = FALSE;
+    call MLME_SET.macShortAddress(TOS_NODE_ID);
+
+    // scan only one channel
+    channelMask = ((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);
+    call MLME_SCAN.request  (
+                           PASSIVE_SCAN,           // ScanType
+                           channelMask,            // ScanChannels
+                           scanDuration,           // ScanDuration
+                           0x00,                   // ChannelPage
+                           0,                      // EnergyDetectListNumEntries
+                           NULL,                   // EnergyDetectList
+                           0,                      // PANDescriptorListNumEntries
+                           NULL,                   // PANDescriptorList
+                           0                       // 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 our coordinator...
+      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 the 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.macCoordShortAddress(m_PANDescriptor.CoordAddress.shortAddress);
+      call MLME_SET.macPANId(m_PANDescriptor.CoordPANId);
+      call MLME_SYNC.request(m_PANDescriptor.LogicalChannel, m_PANDescriptor.ChannelPage, TRUE);
+      call Frame.setAddressingFields(
+          &m_frame,                
+          ADDR_MODE_SHORT_ADDRESS,        // SrcAddrMode,
+          ADDR_MODE_SHORT_ADDRESS,        // DstAddrMode,
+          m_PANDescriptor.CoordPANId,     // DstPANId,
+          &m_PANDescriptor.CoordAddress,  // DstAddr,
+          NULL                            // security
+          );
+      post packetSendTask(); 
+    } else
+      startApp();
+  }
+
+  task void packetSendTask()
+  {
+    if (!m_sending && m_isPANDescriptorValid &&
+        call MCPS_DATA.request  (
+          &m_frame,                         // frame,
+          m_payloadLen,                     // payloadLength,
+          0,                                // msduHandle,
+          TX_OPTIONS_ACK                    // TxOptions,
+          ) == IEEE154_SUCCESS)
+      m_sending = TRUE;
+  }
+
+  event void MCPS_DATA.confirm    (
+                          message_t *msg,
+                          uint8_t msduHandle,
+                          ieee154_status_t status,
+                          uint32_t timestamp
+                        )
+  {
+    m_sending = FALSE;
+    if (status == IEEE154_SUCCESS && m_ledCount++ == 20){
+      m_ledCount = 0;
+      call Leds.led1Toggle();
+    }
+    post packetSendTask(); 
+  }
+
+  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 message_t* MCPS_DATA.indication (message_t* frame)
+  {
+    // we don't expect data
+    return frame;
+  }
+
+}
diff --git a/apps/tests/tkn154/TestIndirect/README.txt b/apps/tests/tkn154/TestIndirect/README.txt
new file mode 100644 (file)
index 0000000..c452520
--- /dev/null
@@ -0,0 +1,43 @@
+README for TestIndirect
+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 additionally in
+every beacon interval it tries to transmit one DATA frame to a device using
+indirect tranmission. A second node that takes the role of a device first scans
+the pre-defined channel for beacons from the coordinator and once it finds a
+beacon it tries to synchronize to and track all future beacons. Whenever the
+coordinator has data to send (indicated in the beacon), the device extracts the
+DATA frame from the coordinator.
+
+The third LED (Telos: blue) is toggled whenever the coordinator has transmitted
+a beacon, it is not used on the device. On the coordinator the second LED
+(Telos: green) is toggled for every transmitted DATA frames. On a device the
+second LED is toggled for every received DATA frame. 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 device
+
+    $ 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$
+
diff --git a/apps/tests/tkn154/TestIndirect/app_profile.h b/apps/tests/tkn154/TestIndirect/app_profile.h
new file mode 100644 (file)
index 0000000..185bbcd
--- /dev/null
@@ -0,0 +1,48 @@
+/* 
+ * 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 = 0x1152,
+  DEVICE_ADDRESS = 0x4342,
+  COORDINATOR_ADDRESS = 0x5341,
+  BEACON_ORDER = 5,
+  SUPERFRAME_ORDER = 5,
+};
+
+#endif
diff --git a/apps/tests/tkn154/TestIndirect/coordinator/Makefile b/apps/tests/tkn154/TestIndirect/coordinator/Makefile
new file mode 100644 (file)
index 0000000..acdecfd
--- /dev/null
@@ -0,0 +1,4 @@
+COMPONENT=TestIndirectAppC
+PFLAGS += -DIEEE154_BEACON_SYNC_DISABLED -DIEEE154_SCAN_DISABLED
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestIndirect/coordinator/TestCoordSenderC.nc b/apps/tests/tkn154/TestIndirect/coordinator/TestCoordSenderC.nc
new file mode 100644 (file)
index 0000000..454cbda
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * 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 TestCoordSenderC
+{
+  uses {
+    interface Boot;
+    interface MCPS_DATA;
+    interface MLME_RESET;
+    interface MLME_START;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface Leds;
+    interface IEEE154Frame as Frame;
+    interface IEEE154TxBeaconPayload;
+    interface Packet;
+  }
+} implementation {
+
+  message_t m_frame;
+  uint8_t m_payloadLen;
+
+  event void Boot.booted() {
+    char payload[] = "Hello Device!";
+    uint8_t *payloadRegion;
+    ieee154_address_t deviceShortAddress;
+
+    // construct the frame
+    m_payloadLen = strlen(payload);
+    payloadRegion = call Packet.getPayload(&m_frame, m_payloadLen);
+    deviceShortAddress.shortAddress = DEVICE_ADDRESS; // destination
+    if (m_payloadLen <= call Packet.maxPayloadLength()){
+      memcpy(payloadRegion, payload, m_payloadLen);
+      call Frame.setAddressingFields(
+          &m_frame,                
+          ADDR_MODE_SHORT_ADDRESS, // SrcAddrMode,
+          ADDR_MODE_SHORT_ADDRESS, // DstAddrMode,
+          PAN_ID,                  // DstPANId,
+          &deviceShortAddress,     // DstAddr,
+          NULL                     // security
+          );
+      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(FALSE);
+    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,                // CoordRealignSecurity
+                          0                 // BeaconSecurity
+                        );
+  }
+
+  void dataRequest()
+  {
+    call MCPS_DATA.request  (
+        &m_frame,                                 // msdu,
+        m_payloadLen,                             // payloadLength,
+        0,                                        // msduHandle,
+        TX_OPTIONS_ACK | TX_OPTIONS_INDIRECT      // TxOptions,
+        );
+  }
+
+  event void MLME_START.confirm(ieee154_status_t status)
+  {
+    if (status == IEEE154_SUCCESS)
+      dataRequest();
+  }
+
+  event void MCPS_DATA.confirm(
+                          message_t *msg,
+                          uint8_t msduHandle,
+                          ieee154_status_t status,
+                          uint32_t Timestamp
+                        )
+  {
+    if (status == IEEE154_SUCCESS)
+      call Leds.led1Toggle();
+    dataRequest();
+  }
+
+  event message_t* MCPS_DATA.indication ( message_t* frame)
+  {
+    return frame;
+  }
+
+  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/TestIndirect/coordinator/TestIndirectAppC.nc b/apps/tests/tkn154/TestIndirect/coordinator/TestIndirectAppC.nc
new file mode 100644 (file)
index 0000000..c64332b
--- /dev/null
@@ -0,0 +1,52 @@
+/* 
+ * 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 TestIndirectAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC;
+  components TestCoordSenderC 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.MCPS_DATA -> Ieee802154MacC;
+  App.Frame -> Ieee802154MacC;
+  App.IEEE154TxBeaconPayload -> Ieee802154MacC;
+  App.Packet -> Ieee802154MacC;
+
+}
diff --git a/apps/tests/tkn154/TestIndirect/device/Makefile b/apps/tests/tkn154/TestIndirect/device/Makefile
new file mode 100644 (file)
index 0000000..09b0d21
--- /dev/null
@@ -0,0 +1,4 @@
+COMPONENT=TestIndirectAppC
+PFLAGS += -DIEEE154_BEACON_TX_DISABLED
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestIndirect/device/TestDeviceReceiverC.nc b/apps/tests/tkn154/TestIndirect/device/TestDeviceReceiverC.nc
new file mode 100644 (file)
index 0000000..45396db
--- /dev/null
@@ -0,0 +1,163 @@
+/* 
+ * 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 TestDeviceReceiverC
+{
+  uses {
+    interface Boot;
+    interface MCPS_DATA;
+    interface MLME_RESET;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface MLME_SCAN;
+    interface MLME_SYNC;
+    interface MLME_BEACON_NOTIFY;
+    interface MLME_SYNC_LOSS;
+    interface IEEE154BeaconFrame as BeaconFrame;
+    interface Leds;
+  }
+} implementation {
+
+  ieee154_address_t m_coordAddress;
+  uint8_t m_coordAddressMode;
+  ieee154_macPANId_t m_coordPANID;
+  ieee154_PANDescriptor_t m_PANDescriptor;
+  bool m_isPANDescriptorValid;
+  void startApp();
+
+  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)
+      startApp();
+  }
+
+  void startApp()
+  {
+    ieee154_phyChannelsSupported_t channel;
+    uint8_t scanDuration = BEACON_ORDER;
+
+    // in this application the coordinator assumes that 
+    // the device has a certain short address    
+    call MLME_SET.macShortAddress(DEVICE_ADDRESS);
+    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);
+    call MLME_SCAN.request  (
+                           PASSIVE_SCAN,           // ScanType
+                           channel,                // ScanChannels
+                           scanDuration,           // ScanDuration
+                           0x00,                   // ChannelPage
+                           0,                      // EnergyDetectListNumEntries
+                           NULL,                   // EnergyDetectList
+                           0,                      // PANDescriptorListNumEntries
+                           NULL,                   // PANDescriptorList
+                           0                       // security
+                        );
+  }
+
+  event message_t* MLME_BEACON_NOTIFY.indication (message_t* frame)
+  {
+    // received a beacon frame during SCAN
+    ieee154_phyCurrentPage_t page = call MLME_GET.phyCurrentPage();
+
+    if (!m_isPANDescriptorValid && 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;
+      }
+    }
+    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){
+      // set the macAutoRequest attribute to TRUE, so indirect
+      // transmissions are automatically carried through
+      call MLME_SET.macAutoRequest(TRUE);
+      call MLME_SET.macCoordShortAddress(m_PANDescriptor.CoordAddress.shortAddress);
+      call MLME_SET.macPANId(m_PANDescriptor.CoordPANId);
+      call MLME_SYNC.request(m_PANDescriptor.LogicalChannel, m_PANDescriptor.ChannelPage, TRUE);
+    } else
+      startApp();
+  }
+
+  event void MCPS_DATA.confirm(
+                          message_t *msg,
+                          uint8_t msduHandle,
+                          ieee154_status_t status,
+                          uint32_t Timestamp
+                        )
+  {
+  }
+
+  event void MLME_SYNC_LOSS.indication(
+                          ieee154_status_t lossReason,
+                          uint16_t PANId,
+                          uint8_t LogicalChannel,
+                          uint8_t ChannelPage,
+                          ieee154_security_t *security)
+  {
+    call Leds.led1Off();
+    startApp();
+  }
+
+  event message_t* MCPS_DATA.indication (message_t* frame)
+  {
+    call Leds.led1Toggle();
+    return frame;
+  }
+}
diff --git a/apps/tests/tkn154/TestIndirect/device/TestIndirectAppC.nc b/apps/tests/tkn154/TestIndirect/device/TestIndirectAppC.nc
new file mode 100644 (file)
index 0000000..4583acb
--- /dev/null
@@ -0,0 +1,53 @@
+/* 
+ * 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 TestIndirectAppC
+{
+} implementation {
+  components MainC, LedsC, Ieee802154MacC;
+  components TestDeviceReceiverC as App;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+  App.MLME_SCAN -> Ieee802154MacC;
+  App.MLME_SYNC -> Ieee802154MacC;
+  App.MLME_BEACON_NOTIFY -> Ieee802154MacC;
+  App.MLME_SYNC_LOSS -> Ieee802154MacC;
+  App.MCPS_DATA -> Ieee802154MacC;
+  App.BeaconFrame -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestPromiscuous/Makefile b/apps/tests/tkn154/TestPromiscuous/Makefile
new file mode 100644 (file)
index 0000000..1aabe6f
--- /dev/null
@@ -0,0 +1,5 @@
+COMPONENT=TestPromiscuousAppC
+PFLAGS += -DIEEE154_BEACON_TX_DISABLED -DIEEE154_BEACON_SYNC_DISABLED -DIEEE154_SCAN_DISABLED
+PFLAGS += -DPRINTF_BUFFER_SIZE=1000
+CFLAGS += -I$(TOSDIR)/lib/printf
+include ../Makefile.include
diff --git a/apps/tests/tkn154/TestPromiscuous/README.txt b/apps/tests/tkn154/TestPromiscuous/README.txt
new file mode 100644 (file)
index 0000000..83a3b9c
--- /dev/null
@@ -0,0 +1,35 @@
+README for TestPromiscuous
+Author/Contact: tinyos-help@millennium.berkeley.edu
+
+Description:
+
+In this application the node enables promiscuous mode, i.e. its radio is
+switched to receive mode and all incoming frames that pass the CRC check are
+signalled to the upper layer. The application uses the TinyOS printf library
+(tos/lib/printf) to output information on the MAC header fields and payload for
+every received frame over the serial port. The second (TelosB: green) LED is
+toggled whenever a frame is received.
+
+Tools: The printf java client in $TOSDIR/../apps/tests/TestPrintf
+
+Usage: 
+
+Install the application on a node
+
+    $ make telosb install
+
+Start the printf client on 
+
+    $ cd $TOSDIR/../apps/tests/TestPrintf
+    $ make telosb
+    $ java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb
+
+(http://docs.tinyos.net/ has a section on how to use the TinyOS printf library)
+
+Known bugs/limitations:
+
+- Currently this application only works on TelosB nodes
+- The timestamps for ACKs are incorrect
+
+$Id$
+
diff --git a/apps/tests/tkn154/TestPromiscuous/TestPromiscuousAppC.nc b/apps/tests/tkn154/TestPromiscuous/TestPromiscuousAppC.nc
new file mode 100644 (file)
index 0000000..e48ac50
--- /dev/null
@@ -0,0 +1,52 @@
+/* 
+ * 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 TestPromiscuousAppC
+{
+} implementation {
+ components MainC, TestPromiscuousC as App, LedsC, 
+            Ieee802154MacC as Ieee802154MacC;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+  App.MCPS_DATA -> Ieee802154MacC;
+  App.Frame -> Ieee802154MacC;
+  App.BeaconFrame -> Ieee802154MacC;
+  App.PromiscuousMode -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestPromiscuous/TestPromiscuousC.nc b/apps/tests/tkn154/TestPromiscuous/TestPromiscuousC.nc
new file mode 100644 (file)
index 0000000..bc3699f
--- /dev/null
@@ -0,0 +1,158 @@
+/* 
+ * 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"
+module TestPromiscuousC
+{
+  uses {
+    interface Boot;
+    interface MLME_RESET;
+    interface MLME_SET;
+    interface MLME_GET;
+    interface MCPS_DATA;
+    interface Leds;
+    interface IEEE154Frame as Frame;
+    interface IEEE154BeaconFrame as BeaconFrame;
+    interface SplitControl as PromiscuousMode;
+  }
+} implementation {
+
+  const char *m_frametype[] = {"Beacon", "Data","Acknowledgement","MAC command", "Unknown"};
+  const char *m_cmdframetype[] = {"unknown command", "Association request","Association response",
+    "Disassociation notification","Data request","PAN ID conflict notification",
+    "Orphan notification", "Beacon request", "Coordinator realignment", "GTS request"};
+
+  enum {
+    RADIO_CHANNEL = 26,
+  };
+
+  event void Boot.booted() {
+    call MLME_RESET.request(TRUE, BEACON_ENABLED_PAN);
+  }
+
+  event void MLME_RESET.confirm(ieee154_status_t status)
+  {
+    call MLME_SET.phyCurrentChannel(RADIO_CHANNEL);
+    call PromiscuousMode.start();
+  }
+
+  event message_t* MCPS_DATA.indication (message_t* frame)
+  {
+    uint8_t i;
+    uint8_t *payload = call Frame.getPayload(frame);
+    uint8_t payloadLen = call Frame.getPayloadLength(frame);
+    uint8_t *header = call Frame.getHeader(frame);
+    uint8_t headerLen = call Frame.getHeaderLength(frame);
+    uint8_t SrcAddrMode, DstAddrMode;
+    uint8_t frameType, cmdFrameType;
+    ieee154_address_t SrcAddress, DstAddress;
+    uint16_t SrcPANId=0, DstPANId=0;
+
+    if (call Frame.hasStandardCompliantHeader(frame)){
+      frameType = call Frame.getFrameType(frame);
+      if (frameType > FRAMETYPE_CMD)
+        frameType = 4;
+      call Frame.getSrcPANId(frame, &SrcPANId);
+      call Frame.getDstPANId(frame, &DstPANId);
+      call Frame.getSrcAddr(frame, &SrcAddress);
+      call Frame.getDstAddr(frame, &DstAddress);
+      SrcAddrMode = call Frame.getSrcAddrMode(frame);
+      DstAddrMode = call Frame.getDstAddrMode(frame);
+
+      printf("\n");
+      printf("Frametype: %s", m_frametype[frameType]);
+      if (frameType == FRAMETYPE_CMD){
+        cmdFrameType = payload[0];
+        if (cmdFrameType > 9)
+          cmdFrameType = 0;
+        printf(" (%s)", m_cmdframetype[cmdFrameType]);
+      }
+      printf("\n");
+      printf("SrcAddrMode: %d\n", SrcAddrMode);
+      printf("SrcAddr: ");
+      if (SrcAddrMode == ADDR_MODE_SHORT_ADDRESS){
+        printf("0x%hx\n", SrcAddress.shortAddress);
+        printf("SrcPANId: 0x%x\n", SrcPANId);
+      } else if (SrcAddrMode == ADDR_MODE_EXTENDED_ADDRESS){
+        for (i=0; i<8; i++)
+          printf("0x%hx ", ((uint8_t*) &(SrcAddress.extendedAddress))[i]);
+        printf("\n");
+        printf("SrcPANId: 0x%x\n", SrcPANId);
+      } else printf("\n");
+      printf("DstAddrMode: %d\n", DstAddrMode);
+      printf("DstAddr: ");
+      if ( DstAddrMode == ADDR_MODE_SHORT_ADDRESS){
+        printf("0x%hx\n", DstAddress.shortAddress);
+        printf("DestPANId: 0x%x\n", DstPANId);
+      } else if  ( DstAddrMode == ADDR_MODE_EXTENDED_ADDRESS) {
+        for (i=0; i<8; i++)
+          printf("0x%hx ", ((uint8_t*) &(DstAddress.extendedAddress))[i]);
+        printf("\n");    
+        printf("DestPANId: 0x%x\n", DstPANId);
+      } else printf("\n");
+
+      printf("DSN: %d\n", call Frame.getDSN(frame));
+      printf("MHRLen: %d\n", headerLen);
+      printf("MHR: ");
+      for (i=0; i<headerLen; i++){
+        printf("0x%hx ", header[i]);
+      }
+      printf("\n");      
+      printf("PayloadLen: %d\n", payloadLen);
+      printf("Payload: ");
+      for (i=0; i<payloadLen; i++){
+        printf("0x%hx ", payload[i]);
+      }
+      printf("\n");
+      printf("MpduLinkQuality: %d\n", call Frame.getLinkQuality(frame));
+
+      printf("Timestamp: ");
+      if (call Frame.isTimestampValid(frame))
+        printf("%ld\n", call Frame.getTimestamp(frame));
+      else
+        printf("INVALID\n");
+      printfflush(); 
+    }
+    call Leds.led1Toggle();
+    return frame;
+  }
+
+  event void MCPS_DATA.confirm( message_t *msg, uint8_t msduHandle, ieee154_status_t status, uint32_t Timestamp){}
+  event void PromiscuousMode.startDone(error_t error) 
+  {
+    printf("\n*** Radio is now in promiscuous mode, listening on channel %d ***\n", RADIO_CHANNEL);
+    printfflush(); 
+  }
+  event void PromiscuousMode.stopDone(error_t error) {}
+}
diff --git a/apps/tests/tkn154/TestStartSync/README.txt b/apps/tests/tkn154/TestStartSync/README.txt
new file mode 100644 (file)
index 0000000..e58dc33
--- /dev/null
@@ -0,0 +1,41 @@
+README for TestStartSync
+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 with a frequency
+defined in the app_profile.h file. A second node acts as a device; it first
+scans all available channels for beacons from the coordinator and once it finds
+a beacon it tries to synchronize to and track all future beacons. 
+
+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 after it has started transmitting
+beacons. On a device the second LED is switched on whenever the device is
+synchronized to the coordinator's beacons. 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 beacon period is not standard-compliant, because TelosB lacks a
+  clock with sufficient precision/accuracy
+
+$Id$
+
diff --git a/apps/tests/tkn154/TestStartSync/app_profile.h b/apps/tests/tkn154/TestStartSync/app_profile.h
new file mode 100644 (file)
index 0000000..366f111
--- /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 = 0x7761,
+  COORDINATOR_ADDRESS = 0x1832,
+  BEACON_ORDER = 5,
+  SUPERFRAME_ORDER = 5,
+};
+
+#endif
diff --git a/apps/tests/tkn154/TestStartSync/coordinator/Makefile b/apps/tests/tkn154/TestStartSync/coordinator/Makefile
new file mode 100644 (file)
index 0000000..13db21c
--- /dev/null
@@ -0,0 +1,3 @@
+COMPONENT=TestStartSyncAppC
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestStartSync/coordinator/TestCoordC.nc b/apps/tests/tkn154/TestStartSync/coordinator/TestCoordC.nc
new file mode 100644 (file)
index 0000000..f752bda
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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_SET;
+    interface MLME_GET;
+    interface Leds;
+    interface IEEE154TxBeaconPayload;
+  }
+} implementation {
+
+  uint8_t m_beaconPayload[] = {0x01, 0x02, 0x03, 0x04, 0x05};
+
+  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){
+      call MLME_SET.macShortAddress(COORDINATOR_ADDRESS);
+      call MLME_SET.macAssociationPermit(FALSE);
+      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)
+  {
+    if (status == IEEE154_SUCCESS){
+      call IEEE154TxBeaconPayload.setBeaconPayload(m_beaconPayload, sizeof(m_beaconPayload));
+      call Leds.led1On();
+    }
+  }
+
+  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/TestStartSync/coordinator/TestStartSyncAppC.nc b/apps/tests/tkn154/TestStartSync/coordinator/TestStartSyncAppC.nc
new file mode 100644 (file)
index 0000000..d0913c7
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * 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 TestStartSyncAppC
+{
+} implementation {
+
+  components MainC, LedsC, Ieee802154MacC as Ieee802154MacC;
+  components TestCoordC as App;
+
+  MainC.Boot <- App;
+  App.MLME_START -> Ieee802154MacC;
+  App.IEEE154TxBeaconPayload -> Ieee802154MacC;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+}
diff --git a/apps/tests/tkn154/TestStartSync/device/Makefile b/apps/tests/tkn154/TestStartSync/device/Makefile
new file mode 100644 (file)
index 0000000..1f9448f
--- /dev/null
@@ -0,0 +1,4 @@
+COMPONENT=TestStartSyncAppC
+PFLAGS += -DIEEE154_BEACON_TX_DISABLED
+CFLAGS += -I$(shell pwd)/..
+include ../../Makefile.include
diff --git a/apps/tests/tkn154/TestStartSync/device/TestDeviceC.nc b/apps/tests/tkn154/TestStartSync/device/TestDeviceC.nc
new file mode 100644 (file)
index 0000000..93713b8
--- /dev/null
@@ -0,0 +1,159 @@
+/* 
+ * 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_BEACON_NOTIFY;
+    interface MLME_SYNC_LOSS;
+    interface Leds;
+    interface IEEE154BeaconFrame as BeaconFrame;
+  }
+} implementation {
+
+  enum {
+    NUM_PAN_DESCRIPTORS = 10,
+  };
+  ieee154_PANDescriptor_t m_PANDescriptor[NUM_PAN_DESCRIPTORS];
+  void startApp();
+
+  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)
+      startApp();
+  }
+
+  void startApp()
+  {
+    ieee154_phyChannelsSupported_t supportedChannels;
+    uint8_t scanDuration = BEACON_ORDER;
+
+    // set the short address to whatever was passed 
+    // as a parameter to make system ("make install,X")
+    call MLME_SET.macShortAddress(TOS_NODE_ID); 
+    supportedChannels = call MLME_GET.phyChannelsSupported();
+
+    // setting the macAutoRequest attribute to TRUE means
+    // that during the scan beacons will not be signalled
+    // through MLME_BEACON_NOTIFY
+    call MLME_SET.macAutoRequest(TRUE);
+    call MLME_SCAN.request  (
+        PASSIVE_SCAN,           // ScanType
+        supportedChannels,      // ScanChannels
+        scanDuration,           // ScanDuration
+        0x00,                   // ChannelPage
+        0,                      // EnergyDetectListNumEntries
+        NULL,                   // EnergyDetectList
+        NUM_PAN_DESCRIPTORS,    // 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 i;
+    switch (status){
+      case IEEE154_NO_BEACON:
+        startApp();
+        break;
+      case IEEE154_SUCCESS:
+        if (PANDescriptorListNumEntries > 0){
+          for (i=0; i<PANDescriptorListNumEntries; i++)
+            if (PANDescriptorList[i].CoordAddrMode == ADDR_MODE_SHORT_ADDRESS &&
+                PANDescriptorList[i].CoordPANId == PAN_ID &&
+                PANDescriptorList[i].CoordAddress.shortAddress == COORDINATOR_ADDRESS)
+              break;
+          if (i == PANDescriptorListNumEntries){
+            // found no matching entry
+            startApp();
+          } else {
+            call MLME_SET.macAutoRequest(FALSE); // from now on: give me the beacons
+            call MLME_SET.macPANId(PANDescriptorList[i].CoordPANId);
+            call MLME_SET.macCoordShortAddress(PANDescriptorList[i].CoordAddress.shortAddress);
+            call MLME_SYNC.request(PANDescriptorList[i].LogicalChannel, ChannelPage, TRUE);
+          }
+        }
+        break;
+      default:
+        break;
+    }
+  }
+
+  event message_t* MLME_BEACON_NOTIFY.indication (
+                          message_t* frame
+                        )
+  {
+    ieee154_macBSN_t beaconSequenceNumber = call BeaconFrame.getBSN(frame);
+    if (beaconSequenceNumber & 1)
+      call Leds.led2On();
+    else
+      call Leds.led2Off();    
+    call Leds.led1On();
+    return frame;
+  }
+
+  event void MLME_SYNC_LOSS.indication(
+                          ieee154_status_t lossReason,
+                          uint16_t PANId,
+                          uint8_t LogicalChannel,
+                          uint8_t ChannelPage,
+                          ieee154_security_t *security)
+  {
+    call Leds.led1Off();
+    startApp();
+  }
+}
diff --git a/apps/tests/tkn154/TestStartSync/device/TestStartSyncAppC.nc b/apps/tests/tkn154/TestStartSync/device/TestStartSyncAppC.nc
new file mode 100644 (file)
index 0000000..9373400
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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 TestStartSyncAppC
+{
+} implementation {
+
+  components MainC, LedsC, Ieee802154MacC as Ieee802154MacC;
+  components TestDeviceC as App;
+
+  App.MLME_SCAN -> Ieee802154MacC;
+  App.MLME_SYNC -> Ieee802154MacC;
+  App.MLME_BEACON_NOTIFY -> Ieee802154MacC;
+  App.MLME_SYNC_LOSS -> Ieee802154MacC;
+  App.BeaconFrame -> Ieee802154MacC;
+
+  MainC.Boot <- App;
+  App.Leds -> LedsC;
+  App.MLME_RESET -> Ieee802154MacC;
+  App.MLME_SET -> Ieee802154MacC;
+  App.MLME_GET -> Ieee802154MacC;
+
+#ifdef PRINTF_ENABLED
+  components PrintfC;
+  App.PrintfControl -> PrintfC;
+  App.PrintfFlush -> PrintfC;
+#endif
+}