/*
- * Copyright (c) 2007, Vanderbilt University
+ * Copyright (c) 2009, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* THE VANDERBILT 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
* Author: Miklos Maroti
*/
-module ActiveMessageLayerC
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+configuration ActiveMessageLayerC
{
provides
{
+ interface AMPacket;
+ interface Packet;
interface AMSend[am_id_t id];
- interface Receive[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 SendNotifier[am_id_t id];
}
+
uses
{
- interface Send as SubSend;
- interface Receive as SubReceive;
- interface AMPacket;
+ interface RadioPacket as SubPacket;
+ interface BareSend as SubSend;
+ interface BareReceive as SubReceive;
interface ActiveMessageConfig as Config;
}
}
implementation
{
-/*----------------- Send -----------------*/
-
- command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len)
- {
- error_t error;
-
- error = call Config.checkPacket(msg);
- if( error != SUCCESS )
- return error;
-
- call AMPacket.setSource(msg, call AMPacket.address());
- call AMPacket.setGroup(msg, call AMPacket.localGroup());
- call AMPacket.setType(msg, id);
- call AMPacket.setDestination(msg, addr);
-
- return call SubSend.send(msg, len);
- }
-
- inline event void SubSend.sendDone(message_t* msg, error_t error)
- {
- signal AMSend.sendDone[call AMPacket.type(msg)](msg, error);
- }
-
- inline command error_t AMSend.cancel[am_id_t id](message_t* msg)
- {
- return call SubSend.cancel(msg);
- }
-
- default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error)
- {
- }
-
- inline command uint8_t AMSend.maxPayloadLength[am_id_t id]()
- {
- return call SubSend.maxPayloadLength();
- }
-
- inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len)
- {
- return call SubSend.getPayload(msg, len);
- }
-
-/*----------------- Receive -----------------*/
-
- event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
- {
- am_id_t type = call AMPacket.type(msg);
-
- msg = call AMPacket.isForMe(msg)
- ? signal Receive.receive[type](msg, payload, len)
- : signal Snoop.receive[type](msg, payload, len);
-
- return msg;
- }
-
- 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;
- }
+ components ActiveMessageLayerP, ActiveMessageAddressC;
+ ActiveMessageLayerP.ActiveMessageAddress -> ActiveMessageAddressC;
+
+ AMPacket = ActiveMessageLayerP;
+ Packet = ActiveMessageLayerP;
+ AMSend = ActiveMessageLayerP;
+ Receive = ActiveMessageLayerP.Receive;
+ ReceiveDefault = ActiveMessageLayerP.ReceiveDefault;
+ Snoop = ActiveMessageLayerP.Snoop;
+ SnoopDefault = ActiveMessageLayerP.SnoopDefault;
+ SendNotifier = ActiveMessageLayerP;
+
+ SubPacket = ActiveMessageLayerP;
+ SubSend = ActiveMessageLayerP;
+ SubReceive = ActiveMessageLayerP;
+ Config = ActiveMessageLayerP;
}
--- /dev/null
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+#include <ActiveMessageLayer.h>
+
+module ActiveMessageLayerP
+{
+ provides
+ {
+ interface RadioPacket;
+ interface AMPacket;
+ interface Packet;
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as ReceiveDefault[am_id_t id];
+ interface Receive as Snoop[uint8_t id];
+ interface Receive as SnoopDefault[am_id_t id];
+ interface SendNotifier[am_id_t id];
+ }
+
+ uses
+ {
+ interface RadioPacket as SubPacket;
+ interface BareSend as SubSend;
+ interface BareReceive as SubReceive;
+ interface ActiveMessageConfig as Config;
+ interface ActiveMessageAddress;
+ }
+}
+
+implementation
+{
+ activemessage_header_t* getHeader(message_t* msg)
+ {
+ return ((void*)msg) + call SubPacket.headerLength(msg);
+ }
+
+ void* getPayload(message_t* msg)
+ {
+ return ((void*)msg) + call RadioPacket.headerLength(msg);
+ }
+
+/*----------------- Send -----------------*/
+
+ command error_t AMSend.send[am_id_t id](am_addr_t addr, message_t* msg, uint8_t len)
+ {
+ if( len > call Packet.maxPayloadLength() )
+ return EINVAL;
+
+ if( call Config.checkFrame(msg) != SUCCESS )
+ return FAIL;
+
+ call Packet.setPayloadLength(msg, len);
+ call AMPacket.setSource(msg, call AMPacket.address());
+ call AMPacket.setGroup(msg, call AMPacket.localGroup());
+ call AMPacket.setType(msg, id);
+ call AMPacket.setDestination(msg, addr);
+
+ signal SendNotifier.aboutToSend[id](addr, msg);
+
+ return call SubSend.send(msg);
+ }
+
+ inline event void SubSend.sendDone(message_t* msg, error_t error)
+ {
+ signal AMSend.sendDone[call AMPacket.type(msg)](msg, error);
+ }
+
+ inline command error_t AMSend.cancel[am_id_t id](message_t* msg)
+ {
+ return call SubSend.cancel(msg);
+ }
+
+ default event void AMSend.sendDone[am_id_t id](message_t* msg, error_t error)
+ {
+ }
+
+ inline command uint8_t AMSend.maxPayloadLength[am_id_t id]()
+ {
+ return call Packet.maxPayloadLength();
+ }
+
+ inline command void* AMSend.getPayload[am_id_t id](message_t* msg, uint8_t len)
+ {
+ return call Packet.getPayload(msg, len);
+ }
+
+ default event void SendNotifier.aboutToSend[am_id_t id](am_addr_t addr, message_t* msg)
+ {
+ }
+
+/*----------------- Receive -----------------*/
+
+ event message_t* SubReceive.receive(message_t* msg)
+ {
+ am_id_t id = call AMPacket.type(msg);
+ void* payload = getPayload(msg);
+ uint8_t len = call Packet.payloadLength(msg);
+
+ msg = call AMPacket.isForMe(msg)
+ ? signal Receive.receive[id](msg, payload, len)
+ : signal Snoop.receive[id](msg, payload, len);
+
+ return msg;
+ }
+
+ 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;
+ }
+
+/*----------------- AMPacket -----------------*/
+
+ inline command am_addr_t AMPacket.address()
+ {
+ return call ActiveMessageAddress.amAddress();
+ }
+
+ inline command am_group_t AMPacket.localGroup()
+ {
+ return call ActiveMessageAddress.amGroup();
+ }
+
+ inline command bool AMPacket.isForMe(message_t* msg)
+ {
+ am_addr_t addr = call AMPacket.destination(msg);
+ return addr == call AMPacket.address() || addr == AM_BROADCAST_ADDR;
+ }
+
+ inline command am_addr_t AMPacket.destination(message_t* msg)
+ {
+ return call Config.destination(msg);
+ }
+
+ inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr)
+ {
+ call Config.setDestination(msg, addr);
+ }
+
+ inline command am_addr_t AMPacket.source(message_t* msg)
+ {
+ return call Config.source(msg);
+ }
+
+ inline command void AMPacket.setSource(message_t* msg, am_addr_t addr)
+ {
+ call Config.setSource(msg, addr);
+ }
+
+ inline command am_id_t AMPacket.type(message_t* msg)
+ {
+ return getHeader(msg)->type;
+ }
+
+ inline command void AMPacket.setType(message_t* msg, am_id_t type)
+ {
+ getHeader(msg)->type = type;
+ }
+
+ inline command am_group_t AMPacket.group(message_t* msg)
+ {
+ return call Config.group(msg);
+ }
+
+ inline command void AMPacket.setGroup(message_t* msg, am_group_t grp)
+ {
+ call Config.setGroup(msg, grp);
+ }
+
+ inline async event void ActiveMessageAddress.changed()
+ {
+ }
+
+/*----------------- RadioPacket -----------------*/
+
+ async command uint8_t RadioPacket.headerLength(message_t* msg)
+ {
+ return call SubPacket.headerLength(msg) + sizeof(activemessage_header_t);
+ }
+
+ async command uint8_t RadioPacket.payloadLength(message_t* msg)
+ {
+ return call SubPacket.payloadLength(msg) - sizeof(activemessage_header_t);
+ }
+
+ async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length)
+ {
+ call SubPacket.setPayloadLength(msg, length + sizeof(activemessage_header_t));
+ }
+
+ async command uint8_t RadioPacket.maxPayloadLength()
+ {
+ return call SubPacket.maxPayloadLength() - sizeof(activemessage_header_t);
+ }
+
+ async command uint8_t RadioPacket.metadataLength(message_t* msg)
+ {
+ return call SubPacket.metadataLength(msg);
+ }
+
+ async command void RadioPacket.clear(message_t* msg)
+ {
+ call SubPacket.clear(msg);
+ }
+
+/*----------------- Packet -----------------*/
+
+ command void Packet.clear(message_t* msg)
+ {
+ call RadioPacket.clear(msg);
+ }
+
+ command uint8_t Packet.payloadLength(message_t* msg)
+ {
+ return call RadioPacket.payloadLength(msg);
+ }
+
+ command void Packet.setPayloadLength(message_t* msg, uint8_t len)
+ {
+ call RadioPacket.setPayloadLength(msg, len);
+ }
+
+ command uint8_t Packet.maxPayloadLength()
+ {
+ return call RadioPacket.maxPayloadLength();
+ }
+
+ command void* Packet.getPayload(message_t* msg, uint8_t len)
+ {
+ if( len > call RadioPacket.maxPayloadLength() )
+ return NULL;
+
+ return ((void*)msg) + call RadioPacket.headerLength(msg);
+ }
+}
* 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 VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* THE VANDERBILT 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
* Author: Miklos Maroti
*/
-#include <HplRF230.h>
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+#include <RadioConfig.h>
+
+#ifdef IEEE154FRAMES_ENABLED
+#error "You cannot use ActiveMessageC with IEEE154FRAMES_ENABLED defined"
+#endif
configuration RF230ActiveMessageC
{
- provides
+ provides
{
interface SplitControl;
interface AMSend[am_id_t id];
- interface Receive[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 SendNotifier[am_id_t id];
interface Packet;
interface AMPacket;
+
interface PacketAcknowledgements;
interface LowPowerListening;
+#ifdef PACKET_LINK
+ interface PacketLink;
+#endif
+
+ interface RadioChannel;
interface PacketField<uint8_t> as PacketLinkQuality;
interface PacketField<uint8_t> as PacketTransmitPower;
interface PacketField<uint8_t> as PacketRSSI;
+ interface LocalTime<TRadio> as LocalTimeRadio;
interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
}
implementation
{
- components RF230ActiveMessageP, RF230PacketC, IEEE154PacketC, RadioAlarmC;
+ components RF230RadioC;
-#ifdef RF230_DEBUG
- components AssertC;
-#endif
+ SplitControl = RF230RadioC;
- RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC;
- RF230ActiveMessageP.Packet -> RF230PacketC;
- RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
-
- Packet = RF230PacketC;
- AMPacket = RF230PacketC;
- PacketAcknowledgements = RF230PacketC;
- PacketLinkQuality = RF230PacketC.PacketLinkQuality;
- PacketTransmitPower = RF230PacketC.PacketTransmitPower;
- PacketRSSI = RF230PacketC.PacketRSSI;
- PacketTimeStampRadio = RF230PacketC;
- PacketTimeStampMilli = RF230PacketC;
- LowPowerListening = LowPowerListeningLayerC;
-
- components ActiveMessageLayerC;
-#ifdef TFRAMES_ENABLED
- components new DummyLayerC() as IEEE154NetworkLayerC;
-#else
- components IEEE154NetworkLayerC;
-#endif
-#ifdef LOW_POWER_LISTENING
- components LowPowerListeningLayerC;
-#else
- components new DummyLayerC() as LowPowerListeningLayerC;
-#endif
- components MessageBufferLayerC;
- components UniqueLayerC;
- components TrafficMonitorLayerC;
-#ifdef RF230_SLOTTED_MAC
- components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
-#else
- components RandomCollisionLayerC as CollisionAvoidanceLayerC;
-#endif
- components SoftwareAckLayerC;
- components new DummyLayerC() as CsmaLayerC;
- components RF230LayerC;
-
- SplitControl = LowPowerListeningLayerC;
- AMSend = ActiveMessageLayerC;
- Receive = ActiveMessageLayerC.Receive;
- ReceiveDefault = ActiveMessageLayerC.ReceiveDefault;
- Snoop = ActiveMessageLayerC.Snoop;
- SnoopDefault = ActiveMessageLayerC.SnoopDefault;
-
- ActiveMessageLayerC.Config -> RF230ActiveMessageP;
- ActiveMessageLayerC.AMPacket -> IEEE154PacketC;
- ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC;
- ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC;
-
- IEEE154NetworkLayerC.SubSend -> UniqueLayerC;
- IEEE154NetworkLayerC.SubReceive -> LowPowerListeningLayerC;
-
- // the UniqueLayer is wired at two points
- UniqueLayerC.Config -> RF230ActiveMessageP;
- UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
- LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
- LowPowerListeningLayerC.SubSend -> MessageBufferLayerC;
- LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
-#ifdef LOW_POWER_LISTENING
- LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC;
- LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC;
- LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC;
-#endif
-
- MessageBufferLayerC.Packet -> RF230PacketC;
- MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
- MessageBufferLayerC.RadioReceive -> UniqueLayerC;
- MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+ AMSend = RF230RadioC;
+ Receive = RF230RadioC.Receive;
+ ReceiveDefault = RF230RadioC.ReceiveDefault;
+ Snoop = RF230RadioC.Snoop;
+ SnoopDefault = RF230RadioC.SnoopDefault;
+ SendNotifier = RF230RadioC;
- UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
+ Packet = RF230RadioC.PacketForActiveMessage;
+ AMPacket = RF230RadioC;
- TrafficMonitorLayerC.Config -> RF230ActiveMessageP;
- TrafficMonitorLayerC.SubSend -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubReceive -> CollisionAvoidanceLayerC;
- TrafficMonitorLayerC.SubState -> RF230LayerC;
-
- CollisionAvoidanceLayerC.Config -> RF230ActiveMessageP;
- CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
- CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
+ PacketAcknowledgements = RF230RadioC;
+ LowPowerListening = RF230RadioC;
+#ifdef PACKET_LINK
+ PacketLink = RF230RadioC;
+#endif
- SoftwareAckLayerC.Config -> RF230ActiveMessageP;
- SoftwareAckLayerC.SubSend -> CsmaLayerC;
- SoftwareAckLayerC.SubReceive -> RF230LayerC;
+ RadioChannel = RF230RadioC;
- CsmaLayerC.Config -> RF230ActiveMessageP;
- CsmaLayerC -> RF230LayerC.RadioSend;
- CsmaLayerC -> RF230LayerC.RadioCCA;
+ PacketLinkQuality = RF230RadioC.PacketLinkQuality;
+ PacketTransmitPower = RF230RadioC.PacketTransmitPower;
+ PacketRSSI = RF230RadioC.PacketRSSI;
- RF230LayerC.RF230Config -> RF230ActiveMessageP;
+ LocalTimeRadio = RF230RadioC;
+ PacketTimeStampMilli = RF230RadioC;
+ PacketTimeStampRadio = RF230RadioC;
}
--- /dev/null
+/*
+ * Copyright (c) 2007, Vanderbilt 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 THE VANDERBILT 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 THE VANDERBILT
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THE VANDERBILT 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 THE VANDERBILT UNIVERSITY HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Author: Miklos Maroti
+ */
+
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+#include <RadioConfig.h>
+
+configuration RF230RadioC
+{
+ provides
+ {
+ interface SplitControl;
+
+#ifndef IEEE154FRAMES_ENABLED
+ 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 SendNotifier[am_id_t id];
+
+ interface AMPacket;
+ interface Packet as PacketForActiveMessage;
+#endif
+
+#ifndef TFRAMES_ENABLED
+ interface Ieee154Send;
+ interface Receive as Ieee154Receive;
+ interface SendNotifier as Ieee154Notifier;
+
+ interface Resource as SendResource[uint8_t clint];
+
+ interface Ieee154Packet;
+ interface Packet as PacketForIeee154Message;
+#endif
+
+ interface PacketAcknowledgements;
+ interface LowPowerListening;
+
+#ifdef PACKET_LINK
+ interface PacketLink;
+#endif
+
+ interface RadioChannel;
+
+ interface PacketField<uint8_t> as PacketLinkQuality;
+ interface PacketField<uint8_t> as PacketTransmitPower;
+ interface PacketField<uint8_t> as PacketRSSI;
+
+ interface LocalTime<TRadio> as LocalTimeRadio;
+ interface PacketTimeStamp<TRadio, uint32_t> as PacketTimeStampRadio;
+ interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
+ }
+}
+
+implementation
+{
+ components RF230RadioP, RadioAlarmC;
+
+#ifdef RADIO_DEBUG
+ components AssertC;
+#endif
+
+ RF230RadioP.Ieee154PacketLayer -> Ieee154PacketLayerC;
+ RF230RadioP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
+ RF230RadioP.PacketTimeStamp -> TimeStampingLayerC;
+ RF230RadioP.RF230Packet -> RF230DriverLayerC;
+
+// -------- Active Message
+
+#ifndef IEEE154FRAMES_ENABLED
+ components ActiveMessageLayerC;
+ ActiveMessageLayerC.Config -> RF230RadioP;
+ ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC;
+ ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive;
+ ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket;
+
+ AMSend = ActiveMessageLayerC;
+ Receive = ActiveMessageLayerC.Receive;
+ ReceiveDefault = ActiveMessageLayerC.ReceiveDefault;
+ Snoop = ActiveMessageLayerC.Snoop;
+ SnoopDefault = ActiveMessageLayerC.SnoopDefault;
+ SendNotifier = ActiveMessageLayerC;
+ AMPacket = ActiveMessageLayerC;
+ PacketForActiveMessage = ActiveMessageLayerC;
+#endif
+
+// -------- Automatic RadioSend Resource
+
+#ifndef IEEE154FRAMES_ENABLED
+#ifndef TFRAMES_ENABLED
+ components new AutoResourceAcquireLayerC();
+ AutoResourceAcquireLayerC.Resource -> SendResourceC.Resource[unique(RADIO_SEND_RESOURCE)];
+#else
+ components new DummyLayerC() as AutoResourceAcquireLayerC;
+#endif
+ AutoResourceAcquireLayerC.SubSend -> TinyosNetworkLayerC.TinyosSend;
+#endif
+
+// -------- RadioSend Resource
+
+#ifndef TFRAMES_ENABLED
+ components new SimpleFcfsArbiterC(RADIO_SEND_RESOURCE) as SendResourceC;
+ SendResource = SendResourceC;
+
+// -------- Ieee154 Message
+
+ components Ieee154MessageLayerC;
+ Ieee154MessageLayerC.Ieee154PacketLayer -> Ieee154PacketLayerC;
+ Ieee154MessageLayerC.Ieee154Packet -> Ieee154PacketLayerC;
+ Ieee154MessageLayerC.SubSend -> TinyosNetworkLayerC.Ieee154Send;
+ Ieee154MessageLayerC.SubReceive -> TinyosNetworkLayerC.Ieee154Receive;
+ Ieee154MessageLayerC.RadioPacket -> TinyosNetworkLayerC.Ieee154Packet;
+
+ Ieee154Send = Ieee154MessageLayerC;
+ Ieee154Receive = Ieee154MessageLayerC;
+ Ieee154Notifier = Ieee154MessageLayerC;
+ Ieee154Packet = Ieee154PacketLayerC;
+ PacketForIeee154Message = Ieee154MessageLayerC;
+#endif
+
+// -------- Tinyos Network
+
+ components TinyosNetworkLayerC;
+
+ TinyosNetworkLayerC.SubSend -> UniqueLayerC;
+ TinyosNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
+ TinyosNetworkLayerC.SubPacket -> Ieee154PacketLayerC;
+
+// -------- IEEE 802.15.4 Packet
+
+ components Ieee154PacketLayerC;
+ Ieee154PacketLayerC.SubPacket -> LowPowerListeningLayerC;
+
+// -------- UniqueLayer Send part (wired twice)
+
+ components UniqueLayerC;
+ UniqueLayerC.Config -> RF230RadioP;
+ UniqueLayerC.SubSend -> LowPowerListeningLayerC;
+
+// -------- Low Power Listening
+
+#ifdef LOW_POWER_LISTENING
+ #warning "*** USING LOW POWER LISTENING LAYER"
+ components LowPowerListeningLayerC;
+ LowPowerListeningLayerC.Config -> RF230RadioP;
+ LowPowerListeningLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
+#else
+ components LowPowerListeningDummyC as LowPowerListeningLayerC;
+#endif
+ LowPowerListeningLayerC.SubControl -> MessageBufferLayerC;
+ LowPowerListeningLayerC.SubSend -> PacketLinkLayerC;
+ LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC;
+ LowPowerListeningLayerC.SubPacket -> PacketLinkLayerC;
+ SplitControl = LowPowerListeningLayerC;
+ LowPowerListening = LowPowerListeningLayerC;
+
+// -------- Packet Link
+
+#ifdef PACKET_LINK
+ components PacketLinkLayerC;
+ PacketLink = PacketLinkLayerC;
+ PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
+#else
+ components new DummyLayerC() as PacketLinkLayerC;
+#endif
+ PacketLinkLayerC.SubSend -> MessageBufferLayerC;
+ PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
+
+// -------- MessageBuffer
+
+ components MessageBufferLayerC;
+ MessageBufferLayerC.RadioSend -> TrafficMonitorLayerC;
+ MessageBufferLayerC.RadioReceive -> UniqueLayerC;
+ MessageBufferLayerC.RadioState -> TrafficMonitorLayerC;
+ RadioChannel = MessageBufferLayerC;
+
+// -------- UniqueLayer receive part (wired twice)
+
+ UniqueLayerC.SubReceive -> TrafficMonitorLayerC;
+
+// -------- Traffic Monitor
+
+#ifdef TRAFFIC_MONITOR
+ components TrafficMonitorLayerC;
+#else
+ components new DummyLayerC() as TrafficMonitorLayerC;
+#endif
+ TrafficMonitorLayerC.Config -> RF230RadioP;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+ TrafficMonitorLayerC -> RF230DriverLayerC.RadioState;
+
+// -------- CollisionAvoidance
+
+#ifdef SLOTTED_MAC
+ components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
+#else
+ components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+#endif
+ CollisionAvoidanceLayerC.Config -> RF230RadioP;
+ CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
+ CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
+
+// -------- SoftwareAcknowledgement
+
+ components SoftwareAckLayerC;
+ SoftwareAckLayerC.Config -> RF230RadioP;
+ SoftwareAckLayerC.SubSend -> CsmaLayerC;
+ SoftwareAckLayerC.SubReceive -> RF230DriverLayerC;
+ PacketAcknowledgements = SoftwareAckLayerC;
+
+// -------- Carrier Sense
+
+ components new DummyLayerC() as CsmaLayerC;
+ CsmaLayerC.Config -> RF230RadioP;
+ CsmaLayerC -> RF230DriverLayerC.RadioSend;
+ CsmaLayerC -> RF230DriverLayerC.RadioCCA;
+
+// -------- TimeStamping
+
+ components TimeStampingLayerC;
+ TimeStampingLayerC.LocalTimeRadio -> RF230DriverLayerC;
+ TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
+ PacketTimeStampRadio = TimeStampingLayerC;
+ PacketTimeStampMilli = TimeStampingLayerC;
+
+// -------- MetadataFlags
+
+ components MetadataFlagsLayerC;
+ MetadataFlagsLayerC.SubPacket -> RF230DriverLayerC;
+
+// -------- RF230 Driver
+
+ components RF230DriverLayerC;
+ RF230DriverLayerC.Config -> RF230RadioP;
+ RF230DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
+ PacketTransmitPower = RF230DriverLayerC.PacketTransmitPower;
+ PacketLinkQuality = RF230DriverLayerC.PacketLinkQuality;
+ PacketRSSI = RF230DriverLayerC.PacketRSSI;
+ LocalTimeRadio = RF230DriverLayerC;
+}
* 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 VANDERBILT 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 THE VANDERBILT
* UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
* THE VANDERBILT 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
* Author: Miklos Maroti
*/
+/*
+ * Make active message TOSThreads-compatible by exposing default interfaces
+ *
+ * Author: Chieh-Jan Mike Liang
+ */
+
+#include <RadioConfig.h>
+
configuration ActiveMessageC
{
provides
interface Receive as ReceiveDefault[am_id_t id];
interface Receive as Snoop[uint8_t id];
interface Receive as SnoopDefault[am_id_t id];
+ interface SendNotifier[am_id_t id];
+
interface Packet;
interface AMPacket;
interface PacketAcknowledgements;
interface LowPowerListening;
+#ifdef PACKET_LINK
+ interface PacketLink;
+#endif
interface PacketTimeStamp<TMicro, uint32_t> as PacketTimeStampMicro;
interface PacketTimeStamp<TMilli, uint32_t> as PacketTimeStampMilli;
implementation
{
- components RF230ActiveMessageC as MAC;
-
- SplitControl = MAC;
- AMSend = MAC;
- Receive = MAC.Receive;
- ReceiveDefault = MAC.ReceiveDefault;
- Snoop = MAC.Snoop;
- SnoopDefault = MAC.SnoopDefault;
- Packet = MAC;
- AMPacket = MAC;
-
- PacketAcknowledgements = MAC;
- LowPowerListening = MAC;
- PacketTimeStampMilli = MAC;
- PacketTimeStampMicro = MAC;
+ components RF230ActiveMessageC as MessageC;
+
+ SplitControl = MessageC;
+
+ AMSend = MessageC;
+ Receive = MessageC.Receive;
+ ReceiveDefault = MessageC.ReceiveDefault;
+ Snoop = MessageC.Snoop;
+ SnoopDefault = MessageC.SnoopDefault;
+ SendNotifier = MessageC;
+
+ Packet = MessageC;
+ AMPacket = MessageC;
+
+ PacketAcknowledgements = MessageC;
+ LowPowerListening = MessageC;
+#ifdef PACKET_LINK
+ PacketLink = MessageC;
+#endif
+
+ PacketTimeStampMilli = MessageC;
+ PacketTimeStampMicro = MessageC;
}