apps want to use the radio. Now, TinyOS services have priority over TOSThreads apps on which AM ID they want to use.
# Extra threads Makefile target to enable thread support for tinyos
# Kevin Klues May 16th, 2008
+# Chieh-Jan Mike Liang July 11th, 2008
#Set up flag signifying threads are enabled
THREADS = THREADS
THREADS_ATM1281_DIR = $(TOS_THREADS_DIR)/chips/atm1281
THREADS_ATM1281_INCLUDE_DIRS = -I$(THREADS_ATM1281_DIR)
+#CC2420 specific include directories on tested platforms
+THREADS_CC2420_DIR = $(TOS_THREADS_DIR)/chips/cc2420
+THREADS_CC2420_INCLUDE_DIRS = -I$(THREADS_CC2420_DIR)
+
#Telos specific include directories
THREADS_TELOS_INCLUDE_DIRS = -I$(TOS_THREADS_DIR)/platforms/telosa
#Mica2 specific include directories
-THREADS_MICA2_INCLUDE_DIRS = -I$(TOS_THREADS_DIR)/platforms/mica2/chips/cc1000
+THREADS_MICA2_INCLUDE_DIRS = -I$(TOS_THREADS_DIR)/chips/cc1000 -I$(TOS_THREADS_DIR)/platforms/mica2/chips/cc1000 -I$(TOS_THREADS_DIR)/platforms/mica2
+
+#MicaZ specific include directories
+THREADS_MICAZ_INCLUDE_DIRS = -I$(TOS_THREADS_DIR)/platforms/micaz
#Add CFLAGS for supported platforms
ifneq ($(filter telos telosa telosb tmote eyesIFX eyesIFXv2 shimmer,$(MAKECMDGOALS)),)
endif
ifneq ($(filter micaz,$(MAKECMDGOALS)),)
CFLAGS += $(THREADS_ATM128_INCLUDE_DIRS)
+ CFLAGS += $(THREADS_MICAZ_INCLUDE_DIRS)
endif
ifneq ($(filter iris,$(MAKECMDGOALS)),)
CFLAGS += $(THREADS_ATM1281_INCLUDE_DIRS)
CFLAGS += $(THREADS_ATM128_INCLUDE_DIRS)
endif
+ifneq ($(filter telos telosa telosb tmote micaz shimmer,$(MAKECMDGOALS)),)
+ CFLAGS += $(THREADS_CC2420_INCLUDE_DIRS)
+endif
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+
+/**
+ *
+ * The Active Message layer for the CC1000 radio. This configuration
+ * just layers the AM dispatch (CC1000ActiveMessageM) on top of the
+ * underlying CC1000 radio packet (CC1000CsmaRadioC), which is
+ * inherently an AM packet (acknowledgements based on AM destination
+ * addr and group).
+ *
+ * @author Philip Levis
+ * @date June 19 2005
+ */
+
+configuration CC1000ActiveMessageC {
+ provides {
+ interface SplitControl;
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+ interface AMPacket;
+ interface Packet;
+ interface PacketAcknowledgements;
+ interface LinkPacketMetadata;
+ }
+}
+implementation {
+
+ components CC1000ActiveMessageP as AM, CC1000CsmaRadioC as Radio;
+ components ActiveMessageAddressC as Address;
+
+ SplitControl = Radio;
+ Packet = Radio;
+ PacketAcknowledgements = Radio;
+ LinkPacketMetadata = Radio;
+
+ AMSend = AM;
+ Receive = AM.Receive;
+ ReceiveDefault = AM.ReceiveDefault;
+ Snoop = AM.Snoop;
+ SnoopDefault = AM.SnoopDefault;
+ AMPacket = AM;
+
+ AM.SubSend -> Radio.Send;
+ AM.SubReceive -> Radio.Receive;
+ AM.amAddress -> Address;
+ AM.Packet -> Radio;
+
+}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/**
+ * Implementation component for CC1000ActiveMessageC.
+ *
+ * @author Philip Levis
+ * @date June 19 2006
+ */
+
+module CC1000ActiveMessageP @safe() {
+ provides {
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+ interface AMPacket;
+ }
+ uses {
+ interface Send as SubSend;
+ interface Receive as SubReceive;
+ interface Packet as Packet;
+ command am_addr_t amAddress();
+ }
+}
+implementation {
+
+ cc1000_header_t* ONE getHeader(message_t* ONE amsg) {
+ return TCAST(cc1000_header_t* ONE, (uint8_t*)amsg + offsetof(message_t, data) - sizeof(cc1000_header_t));
+ }
+
+ cc1000_footer_t *getFooter(message_t *amsg) {
+ return (cc1000_footer_t *)(amsg->footer);
+ }
+
+ command error_t AMSend.send[am_id_t id](am_addr_t addr,
+ message_t* amsg,
+ uint8_t len) {
+ cc1000_header_t* header = getHeader(amsg);
+ header->type = id;
+ header->dest = addr;
+ header->source = call AMPacket.address();
+ header->group = TOS_AM_GROUP;
+ return call SubSend.send(amsg, len);
+ }
+
+ command error_t AMSend.cancel[am_id_t id](message_t* msg) {
+ return call SubSend.cancel(msg);
+ }
+
+ event void SubSend.sendDone(message_t* msg, error_t result) {
+ signal AMSend.sendDone[call AMPacket.type(msg)](msg, result);
+ }
+
+ command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
+ return call Packet.maxPayloadLength();
+ }
+
+ command void* AMSend.getPayload[am_id_t id](message_t* m, uint8_t len) {
+ return call Packet.getPayload(m, len);
+ }
+
+ /* Receiving a packet */
+
+ event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) {
+ cc1000_footer_t* msg_footer = getFooter(msg);
+ if(msg_footer->crc == 1) {
+ if (call AMPacket.isForMe(msg)) {
+ return signal Receive.receive[call AMPacket.type(msg)](msg, payload, len);
+ }
+ else {
+ return signal Snoop.receive[call AMPacket.type(msg)](msg, payload, len);
+ }
+ }
+ return msg;
+ }
+
+ command am_addr_t AMPacket.address() {
+ return call amAddress();
+ }
+
+ command am_addr_t AMPacket.destination(message_t* amsg) {
+ cc1000_header_t* header = getHeader(amsg);
+ return header->dest;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ cc1000_header_t* header = getHeader(amsg);
+ return header->source;
+ }
+
+ command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
+ cc1000_header_t* header = getHeader(amsg);
+ header->dest = addr;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ cc1000_header_t* header = getHeader(amsg);
+ header->source = addr;
+ }
+
+ command bool AMPacket.isForMe(message_t* amsg) {
+ return (call AMPacket.destination(amsg) == call AMPacket.address() ||
+ call AMPacket.destination(amsg) == AM_BROADCAST_ADDR);
+ }
+
+ command am_id_t AMPacket.type(message_t* amsg) {
+ cc1000_header_t* header = getHeader(amsg);
+ return header->type;
+ }
+
+ command void AMPacket.setType(message_t* amsg, am_id_t type) {
+ cc1000_header_t* header = getHeader(amsg);
+ header->type = type;
+ }
+
+ command void AMPacket.setGroup(message_t* msg, am_group_t group) {
+ cc1000_header_t* header = getHeader(msg);
+ header->group = group;
+ }
+
+ command am_group_t AMPacket.group(message_t* msg) {
+ cc1000_header_t* header = getHeader(msg);
+ return header->group;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return TOS_AM_GROUP;
+ }
+
+ default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return signal ReceiveDefault.receive[id](msg, payload, len);
+ }
+
+ default event message_t* ReceiveDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return msg;
+ }
+
+ default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return signal SnoopDefault.receive[id](msg, payload, len);
+ }
+
+ default event message_t* SnoopDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return msg;
+ }
+
+ default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t err) {
+ return;
+ }
+
+
+
+}
--- /dev/null
+/*
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ *
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+/**
+ * The Active Message layer for the CC2420 radio. This configuration
+ * just layers the AM dispatch (CC2420ActiveMessageM) on top of the
+ * underlying CC2420 radio packet (CC2420CsmaCsmaCC), which is
+ * inherently an AM packet (acknowledgements based on AM destination
+ * addr and group). Note that snooping may not work, due to CC2420
+ * early packet rejection if acknowledgements are enabled.
+ *
+ * @author Philip Levis
+ * @author David Moss
+ * @version $Revision$ $Date$
+ */
+
+#include "CC2420.h"
+#include "AM.h"
+
+configuration CC2420ActiveMessageC {
+ provides {
+ interface SplitControl;
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+ interface AMPacket;
+ interface Packet;
+ interface CC2420Packet;
+ interface PacketAcknowledgements;
+ interface LinkPacketMetadata;
+ interface RadioBackoff[am_id_t amId];
+ interface LowPowerListening;
+ interface PacketLink;
+ interface SendNotifier[am_id_t amId];
+ }
+}
+implementation {
+
+ components CC2420ActiveMessageP as AM;
+ components CC2420CsmaC as CsmaC;
+ components ActiveMessageAddressC;
+ components UniqueSendC;
+ components UniqueReceiveC;
+ components CC2420TinyosNetworkC;
+ components CC2420PacketC;
+ components CC2420ControlC;
+
+#if defined(LOW_POWER_LISTENING) || defined(ACK_LOW_POWER_LISTENING)
+ components DefaultLplC as LplC;
+#else
+ components DummyLplC as LplC;
+#endif
+
+#if defined(PACKET_LINK)
+ components PacketLinkC as LinkC;
+#else
+ components PacketLinkDummyC as LinkC;
+#endif
+
+
+ RadioBackoff = AM;
+ Packet = AM;
+ AMSend = AM;
+ SendNotifier = AM;
+ Receive = AM.Receive;
+ ReceiveDefault = AM.ReceiveDefault;
+ Snoop = AM.Snoop;
+ SnoopDefault = AM.SnoopDefault;
+ AMPacket = AM;
+ PacketLink = LinkC;
+ LowPowerListening = LplC;
+ CC2420Packet = CC2420PacketC;
+ PacketAcknowledgements = CC2420PacketC;
+ LinkPacketMetadata = CC2420PacketC;
+
+ // SplitControl Layers
+ SplitControl = LplC;
+ LplC.SubControl -> CsmaC;
+
+ // Send Layers
+ AM.SubSend -> UniqueSendC;
+ UniqueSendC.SubSend -> LinkC;
+ LinkC.SubSend -> LplC.Send;
+ LplC.SubSend -> CC2420TinyosNetworkC.Send;
+ CC2420TinyosNetworkC.SubSend -> CsmaC;
+
+ // Receive Layers
+ AM.SubReceive -> LplC;
+ LplC.SubReceive -> UniqueReceiveC.Receive;
+ UniqueReceiveC.SubReceive -> CC2420TinyosNetworkC.Receive;
+ CC2420TinyosNetworkC.SubReceive -> CsmaC;
+
+ AM.ActiveMessageAddress -> ActiveMessageAddressC;
+ AM.CC2420Packet -> CC2420PacketC;
+ AM.CC2420PacketBody -> CC2420PacketC;
+ AM.CC2420Config -> CC2420ControlC;
+
+ AM.SubBackoff -> CsmaC;
+
+}
--- /dev/null
+/*
+ * "Copyright (c) 2005 Stanford University. All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose, without fee, and without written
+ * agreement is hereby granted, provided that the above copyright
+ * notice, the following two paragraphs and the author appear in all
+ * copies of this software.
+ *
+ * IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY
+ * HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
+ * ENHANCEMENTS, OR MODIFICATIONS."
+ */
+
+
+/**
+ * Active message implementation on top of the CC2420 radio. This
+ * implementation uses the 16-bit addressing mode of 802.15.4: the
+ * only additional byte it adds is the AM id byte, as the first byte
+ * of the data payload.
+ *
+ * @author Philip Levis
+ * @version $Revision$ $Date$
+ */
+
+#include "CC2420.h"
+
+module CC2420ActiveMessageP @safe() {
+ provides {
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+ interface AMPacket;
+ interface Packet;
+ interface SendNotifier[am_id_t id];
+ interface RadioBackoff[am_id_t id];
+ }
+
+ uses {
+ interface Send as SubSend;
+ interface Receive as SubReceive;
+ interface CC2420Packet;
+ interface CC2420PacketBody;
+ interface CC2420Config;
+ interface ActiveMessageAddress;
+ interface RadioBackoff as SubBackoff;
+ }
+}
+implementation {
+
+ /***************** AMSend Commands ****************/
+ command error_t AMSend.send[am_id_t id](am_addr_t addr,
+ message_t* msg,
+ uint8_t len) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader( msg );
+ header->type = id;
+ header->dest = addr;
+ header->destpan = call CC2420Config.getPanAddr();
+ header->src = call AMPacket.address();
+
+ signal SendNotifier.aboutToSend[id](addr, msg);
+
+ return call SubSend.send( msg, len );
+ }
+
+ command error_t AMSend.cancel[am_id_t id](message_t* msg) {
+ return call SubSend.cancel(msg);
+ }
+
+ command uint8_t AMSend.maxPayloadLength[am_id_t id]() {
+ return call Packet.maxPayloadLength();
+ }
+
+ command void* AMSend.getPayload[am_id_t id](message_t* m, uint8_t len) {
+ return call Packet.getPayload(m, len);
+ }
+
+ /***************** AMPacket Commands ****************/
+ command am_addr_t AMPacket.address() {
+ return call ActiveMessageAddress.amAddress();
+ }
+
+ command am_addr_t AMPacket.destination(message_t* amsg) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ return header->dest;
+ }
+
+ command am_addr_t AMPacket.source(message_t* amsg) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ return header->src;
+ }
+
+ command void AMPacket.setDestination(message_t* amsg, am_addr_t addr) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ header->dest = addr;
+ }
+
+ command void AMPacket.setSource(message_t* amsg, am_addr_t addr) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ header->src = addr;
+ }
+
+ command bool AMPacket.isForMe(message_t* amsg) {
+ return (call AMPacket.destination(amsg) == call AMPacket.address() ||
+ call AMPacket.destination(amsg) == AM_BROADCAST_ADDR);
+ }
+
+ command am_id_t AMPacket.type(message_t* amsg) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ return header->type;
+ }
+
+ command void AMPacket.setType(message_t* amsg, am_id_t type) {
+ cc2420_header_t* header = call CC2420PacketBody.getHeader(amsg);
+ header->type = type;
+ }
+
+ command am_group_t AMPacket.group(message_t* amsg) {
+ return (call CC2420PacketBody.getHeader(amsg))->destpan;
+ }
+
+ command void AMPacket.setGroup(message_t* amsg, am_group_t grp) {
+ // Overridden intentionally when we send()
+ (call CC2420PacketBody.getHeader(amsg))->destpan = grp;
+ }
+
+ command am_group_t AMPacket.localGroup() {
+ return call CC2420Config.getPanAddr();
+ }
+
+
+ /***************** Packet Commands ****************/
+ command void Packet.clear(message_t* msg) {
+ memset(call CC2420PacketBody.getHeader(msg), 0x0, sizeof(cc2420_header_t));
+ memset(call CC2420PacketBody.getMetadata(msg), 0x0, sizeof(cc2420_metadata_t));
+ }
+
+ command uint8_t Packet.payloadLength(message_t* msg) {
+ return (call CC2420PacketBody.getHeader(msg))->length - CC2420_SIZE;
+ }
+
+ command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
+ (call CC2420PacketBody.getHeader(msg))->length = len + CC2420_SIZE;
+ }
+
+ command uint8_t Packet.maxPayloadLength() {
+ return TOSH_DATA_LENGTH;
+ }
+
+ command void* Packet.getPayload(message_t* msg, uint8_t len) {
+ return call SubSend.getPayload(msg, len);
+ }
+
+
+ /***************** SubSend Events ****************/
+ event void SubSend.sendDone(message_t* msg, error_t result) {
+ signal AMSend.sendDone[call AMPacket.type(msg)](msg, result);
+ }
+
+
+ /***************** SubReceive Events ****************/
+ event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) {
+
+ if(!(call CC2420PacketBody.getMetadata(msg))->crc) {
+ return msg;
+ }
+
+ if (call AMPacket.isForMe(msg)) {
+ return signal Receive.receive[call AMPacket.type(msg)](msg, payload, len);
+ }
+ else {
+ return signal Snoop.receive[call AMPacket.type(msg)](msg, payload, len);
+ }
+ }
+
+
+ /***************** ActiveMessageAddress Events ****************/
+ async event void ActiveMessageAddress.changed() {
+ }
+
+ /***************** CC2420Config Events ****************/
+ event void CC2420Config.syncDone( error_t error ) {
+ }
+
+
+ /***************** RadioBackoff ***********************/
+
+ async event void SubBackoff.requestInitialBackoff(message_t *msg) {
+ signal RadioBackoff.requestInitialBackoff[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
+ }
+
+ async event void SubBackoff.requestCongestionBackoff(message_t *msg) {
+ signal RadioBackoff.requestCongestionBackoff[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
+ }
+ async event void SubBackoff.requestCca(message_t *msg) {
+ // Lower layers than this do not configure the CCA settings
+ signal RadioBackoff.requestCca[(TCAST(cc2420_header_t* ONE,
+ (uint8_t*)msg + offsetof(message_t, data) - sizeof(cc2420_header_t)))->type](msg);
+ }
+
+ async command void RadioBackoff.setInitialBackoff[am_id_t amId](uint16_t backoffTime) {
+ call SubBackoff.setInitialBackoff(backoffTime);
+ }
+
+ /**
+ * Must be called within a requestCongestionBackoff event
+ * @param backoffTime the amount of time in some unspecified units to backoff
+ */
+ async command void RadioBackoff.setCongestionBackoff[am_id_t amId](uint16_t backoffTime) {
+ call SubBackoff.setCongestionBackoff(backoffTime);
+ }
+
+
+ /**
+ * Enable CCA for the outbound packet. Must be called within a requestCca
+ * event
+ * @param ccaOn TRUE to enable CCA, which is the default.
+ */
+ async command void RadioBackoff.setCca[am_id_t amId](bool useCca) {
+ call SubBackoff.setCca(useCca);
+ }
+
+
+
+ /***************** Defaults ****************/
+ default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return signal ReceiveDefault.receive[id](msg, payload, len);
+ }
+
+ default event message_t* ReceiveDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return msg;
+ }
+
+ default event message_t* Snoop.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return signal SnoopDefault.receive[id](msg, payload, len);
+ }
+
+ default event message_t* SnoopDefault.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
+ return msg;
+ }
+
+ default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t err) {
+ }
+
+ default event void SendNotifier.aboutToSend[am_id_t amId](am_addr_t addr, message_t *msg) {
+ }
+
+ default async event void RadioBackoff.requestInitialBackoff[am_id_t id](
+ message_t *msg) {
+ }
+
+ default async event void RadioBackoff.requestCongestionBackoff[am_id_t id](
+ message_t *msg) {
+ }
+
+ default async event void RadioBackoff.requestCca[am_id_t id](
+ message_t *msg) {
+ }
+
+}
CAMP.AMPacket -> AM;
CAMP.PacketAcknowledgements -> AM;
- AM.Receive -> ActiveMessageC.Receive;
- AM.Snoop -> ActiveMessageC.Snoop;
+ AM.Receive -> ActiveMessageC.ReceiveDefault;
+ AM.Snoop -> ActiveMessageC.SnoopDefault;
AM.AMSend -> ActiveMessageC;
}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/*
+ *
+ * Authors: Philip Levis
+ * Date last modified: $Id$
+ *
+ */
+
+/**
+ * The Active Message layer on the mica2 platform. This is a naming wrapper
+ * around the CC1000 Active Message layer.
+ *
+ * @author Philip Levis
+ * @date June 19 2005
+ */
+
+configuration ActiveMessageC {
+ provides {
+ interface SplitControl;
+
+ interface AMSend[uint8_t id];
+ interface Receive[uint8_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+
+ interface Packet;
+ interface AMPacket;
+ interface PacketAcknowledgements;
+ }
+}
+implementation {
+ components CC1000ActiveMessageC as AM;
+
+ SplitControl = AM;
+
+ AMSend = AM;
+ Receive = AM.Receive;
+ ReceiveDefault = AM.ReceiveDefault;
+ Snoop = AM.Snoop;
+ SnoopDefault = AM.SnoopDefault;
+ Packet = AM;
+ AMPacket = AM;
+ PacketAcknowledgements = AM;
+}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/*
+ *
+ * Authors: Philip Levis
+ * Date last modified: $Id$
+ *
+ */
+
+/**
+ *
+ * The Active Message layer on the micaZ platform. This is a naming wrapper
+ * around the CC2420 Active Message layer.
+ *
+ * @author Philip Levis
+ * @date June 19 2005
+ */
+#include "Timer.h"
+
+configuration ActiveMessageC {
+ provides {
+ interface SplitControl;
+
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+
+ interface Packet;
+ interface AMPacket;
+ interface PacketAcknowledgements;
+ interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+ interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+ }
+}
+implementation {
+ components CC2420ActiveMessageC as AM;
+
+ SplitControl = AM;
+
+ AMSend = AM;
+ Receive = AM.Receive;
+ ReceiveDefault = AM.ReceiveDefault;
+ Snoop = AM.Snoop;
+ SnoopDefault = AM.SnoopDefault;
+ Packet = AM;
+ AMPacket = AM;
+ PacketAcknowledgements = AM;
+
+ components CC2420PacketC;
+ PacketTimeStamp32khz = CC2420PacketC;
+ PacketTimeStampMilli = CC2420PacketC;
+}
--- /dev/null
+// $Id$
+
+/*
+ * "Copyright (c) 2004-2005 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
+ *
+ * Copyright (c) 2004-2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704. Attention: Intel License Inquiry.
+ */
+/*
+ *
+ * Authors: Philip Levis
+ * Date last modified: $Id$
+ *
+ */
+
+/**
+ *
+ * The Active Message layer on the Telos platform. This is a naming wrapper
+ * around the CC2420 Active Message layer.
+ *
+ * @author Philip Levis
+ * @version $Revision$ $Date$
+ */
+#include "Timer.h"
+
+configuration ActiveMessageC {
+ provides {
+ interface SplitControl;
+
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[am_id_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+
+ interface Packet;
+ interface AMPacket;
+ interface PacketAcknowledgements;
+ interface PacketTimeStamp<T32khz, uint32_t> as PacketTimeStamp32khz;
+ interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+ }
+}
+implementation {
+ components CC2420ActiveMessageC as AM;
+
+ SplitControl = AM;
+
+ AMSend = AM;
+ Receive = AM.Receive;
+ ReceiveDefault = AM.ReceiveDefault;
+ Snoop = AM.Snoop;
+ SnoopDefault = AM.SnoopDefault;
+ Packet = AM;
+ AMPacket = AM;
+ PacketAcknowledgements = AM;
+
+ components CC2420PacketC;
+ PacketTimeStamp32khz = CC2420PacketC;
+ PacketTimeStampMilli = CC2420PacketC;
+}
/**
* @author Kevin Klues (klueska@cs.stanford.edu)
+ * @author Chieh-Jan Mike Liang (cliang4@cs.jhu.edu)
*/
#include "AM.h"
components ActiveMessageC;
components BlockingActiveMessageC as AM;
BlockingReceive = AM.BlockingReceive[amId];
- AM.Receive[amId] -> ActiveMessageC.Receive[amId];
+ AM.Receive[amId] -> ActiveMessageC.ReceiveDefault[amId];
Packet = AM;
AMPacket = AM;
/**
* @author Kevin Klues (klueska@cs.stanford.edu)
+ * @author Chieh-Jan Mike Liang (cliang4@cs.jhu.edu)
*/
#include "AM.h"
components ActiveMessageC;
components BlockingActiveMessageC as AM;
BlockingReceive = AM.BlockingSnoop[amId];
- AM.Snoop[amId] -> ActiveMessageC.Snoop[amId];
+ AM.Snoop[amId] -> ActiveMessageC.SnoopDefault[amId];
Packet = AM;
AMPacket = AM;