+++ /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
- */
-
-#ifndef __RF212ACTIVEMESSAGE_H__
-#define __RF212ACTIVEMESSAGE_H__
-
-#include <IEEE154MessageLayer.h>
-#include <LowpanNetworkLayer.h>
-#include <ActiveMessageLayer.h>
-#include <MetadataFlagsLayer.h>
-#include <RF212DriverLayer.h>
-#include <TimeStampingLayer.h>
-#include <LowPowerListeningLayer.h>
-#include <PacketLinkLayer.h>
-
-typedef nx_struct rf212packet_header_t
-{
- rf212_header_t rf212;
- ieee154_header_t ieee154;
-#ifndef TFRAMES_ENABLED
- lowpan_header_t lowpan;
-#endif
- activemessage_header_t am;
-} rf212packet_header_t;
-
-typedef nx_struct rf212packet_footer_t
-{
- // the time stamp is not recorded here, time stamped messaged cannot have max length
-} rf212packet_footer_t;
-
-typedef struct rf212packet_metadata_t
-{
-#ifdef LOW_POWER_LISTENING
- lpl_metadata_t lpl;
-#endif
-#ifdef PACKET_LINK
- link_metadata_t link;
-#endif
- timestamp_metadata_t timestamp;
- flags_metadata_t flags;
- rf212_metadata_t rf212;
-} rf212packet_metadata_t;
-
-#endif//__RF212ACTIVEMESSAGE_H__
#include <RadioConfig.h>
+#ifdef IEEE154FRAMES_ENABLED
+#error "You cannot use ActiveMessageC with IEEE154FRAMES_ENABLED defined"
+#endif
+
configuration RF212ActiveMessageC
{
provides
interface Packet;
interface AMPacket;
+
interface PacketAcknowledgements;
interface LowPowerListening;
-
#ifdef PACKET_LINK
interface PacketLink;
#endif
implementation
{
- components RF212ActiveMessageP, RadioAlarmC;
-
-#ifdef RADIO_DEBUG
- components AssertC;
-#endif
-
- RF212ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
- RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
- RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
- RF212ActiveMessageP.ActiveMessagePacket -> ActiveMessageLayerC;
- RF212ActiveMessageP.RF212Packet -> RF212DriverLayerC;
-
-// -------- Active Message
-
- components ActiveMessageLayerC;
- ActiveMessageLayerC.Config -> RF212ActiveMessageP;
- ActiveMessageLayerC.SubSend -> LowpanNetworkLayerC;
- ActiveMessageLayerC.SubReceive -> LowpanNetworkLayerC;
- ActiveMessageLayerC.SubPacket ->LowpanNetworkLayerC;
- AMSend = ActiveMessageLayerC;
- Packet = ActiveMessageLayerC;
- Receive = ActiveMessageLayerC.Receive;
- Snoop = ActiveMessageLayerC.Snoop;
- AMPacket = ActiveMessageLayerC;
- SendNotifier = ActiveMessageLayerC;
-
-// -------- Lowpan Network
-
-#ifdef TFRAMES_ENABLED
- components new DummyLayerC() as LowpanNetworkLayerC;
-#else
- components LowpanNetworkLayerC;
-#endif
- LowpanNetworkLayerC.SubSend -> IEEE154MessageLayerC;
- LowpanNetworkLayerC.SubReceive -> LowPowerListeningLayerC;
- LowpanNetworkLayerC.SubPacket -> IEEE154MessageLayerC;
+ components RF212RadioC;
-// -------- IEEE154 Message
+ SplitControl = RF212RadioC;
- components IEEE154MessageLayerC;
- IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
- IEEE154MessageLayerC.SubSend -> UniqueLayerC;
+ AMSend = RF212RadioC;
+ Receive = RF212RadioC.Receive;
+ Snoop = RF212RadioC.Snoop;
+ SendNotifier = RF212RadioC;
-// -------- UniqueLayer Send part (wired twice)
-
- components UniqueLayerC;
- UniqueLayerC.Config -> RF212ActiveMessageP;
- UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
-// -------- Low Power Listening
-
-#ifdef LOW_POWER_LISTENING
- #warning "*** USING LOW POWER LISTENING LAYER"
- components LowPowerListeningLayerC;
- LowPowerListeningLayerC.Config -> RF212ActiveMessageP;
- 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
+ Packet = RF212RadioC.PacketForActiveMessage;
+ AMPacket = RF212RadioC;
+ PacketAcknowledgements = RF212RadioC;
+ LowPowerListening = RF212RadioC;
#ifdef PACKET_LINK
- #warning "*** USING PACKET LINK LAYER"
- 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 -> RF212ActiveMessageP;
- TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
- TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
- TrafficMonitorLayerC -> RF212DriverLayerC.RadioState;
-
-// -------- CollisionAvoidance
-
-#ifdef SLOTTED_MAC
- components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
-#else
- components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+ PacketLink = RF212RadioC;
#endif
- CollisionAvoidanceLayerC.Config -> RF212ActiveMessageP;
- CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
- CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
-
-// -------- SoftwareAcknowledgement
-
- components SoftwareAckLayerC;
- SoftwareAckLayerC.Config -> RF212ActiveMessageP;
- SoftwareAckLayerC.SubSend -> CsmaLayerC;
- SoftwareAckLayerC.SubReceive -> RF212DriverLayerC;
- PacketAcknowledgements = SoftwareAckLayerC;
-
-// -------- Carrier Sense
-
- components new DummyLayerC() as CsmaLayerC;
- CsmaLayerC.Config -> RF212ActiveMessageP;
- CsmaLayerC -> RF212DriverLayerC.RadioSend;
- CsmaLayerC -> RF212DriverLayerC.RadioCCA;
-
-// -------- TimeStamping
-
- components TimeStampingLayerC;
- TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
- TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
- PacketTimeStampRadio = TimeStampingLayerC;
- PacketTimeStampMilli = TimeStampingLayerC;
-
-// -------- MetadataFlags
- components MetadataFlagsLayerC;
- MetadataFlagsLayerC.SubPacket -> RF212DriverLayerC;
+ RadioChannel = RF212RadioC;
-// -------- RF212 Driver
+ PacketLinkQuality = RF212RadioC.PacketLinkQuality;
+ PacketTransmitPower = RF212RadioC.PacketTransmitPower;
+ PacketRSSI = RF212RadioC.PacketRSSI;
- components RF212DriverLayerC;
- RF212DriverLayerC.Config -> RF212ActiveMessageP;
- RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
- PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
- PacketLinkQuality = RF212DriverLayerC.PacketLinkQuality;
- PacketRSSI = RF212DriverLayerC.PacketRSSI;
- LocalTimeRadio = RF212DriverLayerC;
+ LocalTimeRadio = RF212RadioC;
+ PacketTimeStampMilli = RF212RadioC;
+ PacketTimeStampRadio = RF212RadioC;
}
+++ /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
- */
-
-#include <RF212ActiveMessage.h>
-#include <RadioConfig.h>
-#include <Tasklet.h>
-
-module RF212ActiveMessageP
-{
- provides
- {
- interface RF212DriverConfig;
- interface SoftwareAckConfig;
- interface UniqueConfig;
- interface CsmaConfig;
- interface TrafficMonitorConfig;
- interface RandomCollisionConfig;
- interface SlottedCollisionConfig;
- interface ActiveMessageConfig;
- interface DummyConfig;
-
-#ifdef LOW_POWER_LISTENING
- interface LowPowerListeningConfig;
-#endif
- }
-
- uses
- {
- interface IEEE154MessageLayer;
- interface RadioAlarm;
- interface RadioPacket as ActiveMessagePacket;
- interface RadioPacket as RF212Packet;
-
- interface PacketTimeStamp<TRadio, uint32_t>;
- }
-}
-
-implementation
-{
-
-/*----------------- RF212DriverConfig -----------------*/
-
- async command uint8_t RF212DriverConfig.headerLength(message_t* msg)
- {
- return offsetof(message_t, data) - sizeof(rf212packet_header_t);
- }
-
- async command uint8_t RF212DriverConfig.maxPayloadLength()
- {
- return sizeof(rf212packet_header_t) + TOSH_DATA_LENGTH;
- }
-
- async command uint8_t RF212DriverConfig.metadataLength(message_t* msg)
- {
- return 0;
- }
-
- async command uint8_t RF212DriverConfig.headerPreloadLength()
- {
- // we need the fcf, dsn, destpan and dest
- return 7;
- }
-
- async command bool RF212DriverConfig.requiresRssiCca(message_t* msg)
- {
- return call IEEE154MessageLayer.isDataFrame(msg);
- }
-
-/*----------------- SoftwareAckConfig -----------------*/
-
- async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
- {
- return call IEEE154MessageLayer.requiresAckWait(msg);
- }
-
- async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
- {
- return call IEEE154MessageLayer.isAckFrame(msg);
- }
-
- async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
- {
- return call IEEE154MessageLayer.verifyAckReply(data, ack);
- }
-
- async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
- {
- call IEEE154MessageLayer.setAckRequired(msg, ack);
- }
-
- async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
- {
- return call IEEE154MessageLayer.requiresAckReply(msg);
- }
-
- async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
- {
- call IEEE154MessageLayer.createAckReply(data, ack);
- }
-
-#ifndef SOFTWAREACK_TIMEOUT
-#define SOFTWAREACK_TIMEOUT 1000
-#endif
-
- async command uint16_t SoftwareAckConfig.getAckTimeout()
- {
- return (uint16_t)(SOFTWAREACK_TIMEOUT * RADIO_ALARM_MICROSEC);
- }
-
- tasklet_async command void SoftwareAckConfig.reportChannelError()
- {
-#ifdef TRAFFIC_MONITOR
- signal TrafficMonitorConfig.channelError();
-#endif
- }
-
-/*----------------- UniqueConfig -----------------*/
-
- async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
- {
- return call IEEE154MessageLayer.getDSN(msg);
- }
-
- async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
- {
- call IEEE154MessageLayer.setDSN(msg, dsn);
- }
-
- async command am_addr_t UniqueConfig.getSender(message_t* msg)
- {
- return call IEEE154MessageLayer.getSrcAddr(msg);
- }
-
- tasklet_async command void UniqueConfig.reportChannelError()
- {
-#ifdef TRAFFIC_MONITOR
- signal TrafficMonitorConfig.channelError();
-#endif
- }
-
-/*----------------- ActiveMessageConfig -----------------*/
-
- command am_addr_t ActiveMessageConfig.destination(message_t* msg)
- {
- return call IEEE154MessageLayer.getDestAddr(msg);
- }
-
- command void ActiveMessageConfig.setDestination(message_t* msg, am_addr_t addr)
- {
- call IEEE154MessageLayer.setDestAddr(msg, addr);
- }
-
- command am_addr_t ActiveMessageConfig.source(message_t* msg)
- {
- return call IEEE154MessageLayer.getSrcAddr(msg);
- }
-
- command void ActiveMessageConfig.setSource(message_t* msg, am_addr_t addr)
- {
- call IEEE154MessageLayer.setSrcAddr(msg, addr);
- }
-
- command am_group_t ActiveMessageConfig.group(message_t* msg)
- {
- return call IEEE154MessageLayer.getDestPan(msg);
- }
-
- command void ActiveMessageConfig.setGroup(message_t* msg, am_group_t grp)
- {
- call IEEE154MessageLayer.setDestPan(msg, grp);
- }
-
-/*----------------- CsmaConfig -----------------*/
-
- async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
- {
- return call IEEE154MessageLayer.isDataFrame(msg);
- }
-
-/*----------------- TrafficMonitorConfig -----------------*/
-
- enum
- {
- TRAFFIC_UPDATE_PERIOD = 100, // in milliseconds
- TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000UL / 32), // 3125
- };
-
- async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
- {
- return TRAFFIC_UPDATE_PERIOD;
- }
-
- async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
- {
- /* We count in bytes, one byte is 32 microsecond. We are conservative here.
- *
- * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
- * frame separation: 5-10 bytes
- * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
- */
-
- uint8_t len = call RF212Packet.payloadLength(msg);
- return call IEEE154MessageLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
- }
-
- async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
- {
- return call IEEE154MessageLayer.getSrcAddr(msg);
- }
-
-/*----------------- RandomCollisionConfig -----------------*/
-
- /*
- * We try to use the same values as in CC2420
- *
- * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
- * CC2420_BACKOFF_PERIOD = 10 jiffies
- * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
- * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
- */
-
- async command uint16_t RandomCollisionConfig.getMinimumBackoff()
- {
- return (uint16_t)(320 * RADIO_ALARM_MICROSEC);
- }
-
- async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg)
- {
- return (uint16_t)(9920 * RADIO_ALARM_MICROSEC);
- }
-
- async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
- {
- return (uint16_t)(2240 * RADIO_ALARM_MICROSEC);
- }
-
- async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
- {
- uint16_t time;
-
- // TODO: maybe we should use the embedded timestamp of the message
- time = call RadioAlarm.getNow();
-
- // estimated response time (download the message, etc) is 5-8 bytes
- if( call IEEE154MessageLayer.requiresAckReply(msg) )
- time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
- else
- time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC);
-
- return time;
- }
-
- tasklet_async event void RadioAlarm.fired()
- {
- }
-
-/*----------------- SlottedCollisionConfig -----------------*/
-
- async command uint16_t SlottedCollisionConfig.getInitialDelay()
- {
- return 300;
- }
-
- async command uint8_t SlottedCollisionConfig.getScheduleExponent()
- {
- return 1 + RADIO_ALARM_MILLI_EXP;
- }
-
- async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
- {
- // TODO: check if the timestamp is correct
- return call PacketTimeStamp.timestamp(msg);
- }
-
- async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg)
- {
- // the preamble (4 bytes), SFD (1 byte), plus two extra for safety
- return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
- }
-
- async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
- {
- return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
- }
-
-/*----------------- Dummy -----------------*/
-
- async command void DummyConfig.nothing()
- {
- }
-
-/*----------------- LowPowerListening -----------------*/
-
-#ifdef LOW_POWER_LISTENING
-
- async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
- {
- return call IEEE154MessageLayer.getAckRequired(msg);
- }
-
-#endif
-
-}
#include <RadioConfig.h>
+#ifdef TFRAMES_ENABLED
+#error "You cannot use Ieee154MessageC with TFRAMES_ENABLED defined"
+#endif
+
configuration RF212Ieee154MessageC
{
provides
interface Ieee154Send;
interface Receive as Ieee154Receive;
+ interface SendNotifier;
+
interface Ieee154Packet;
interface Packet;
+ interface Resource as RadioSendResource[uint8_t clint];
+
interface PacketAcknowledgements;
interface LowPowerListening;
interface PacketLink;
- interface SendNotifier;
interface RadioChannel;
implementation
{
- components RF212ActiveMessageP, RadioAlarmC;
-
-#ifdef RADIO_DEBUG
- components AssertC;
-#endif
-
- RF212ActiveMessageP.IEEE154MessageLayer -> IEEE154MessageLayerC;
- RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
- RF212ActiveMessageP.PacketTimeStamp -> TimeStampingLayerC;
- RF212ActiveMessageP.RF212Packet -> RF212DriverLayerC;
-
-// -------- IEEE154 Message
-
- components IEEE154MessageLayerC;
- IEEE154MessageLayerC.SubPacket -> LowPowerListeningLayerC;
- IEEE154MessageLayerC.SubSend -> UniqueLayerC;
- IEEE154MessageLayerC.SubReceive -> LowPowerListeningLayerC;
- Ieee154Send = IEEE154MessageLayerC;
- Packet = IEEE154MessageLayerC;
- Ieee154Receive = IEEE154MessageLayerC;
- Ieee154Packet = IEEE154MessageLayerC;
- SendNotifier = IEEE154MessageLayerC;
-
-// -------- UniqueLayer Send part (wired twice)
-
- components UniqueLayerC;
- UniqueLayerC.Config -> RF212ActiveMessageP;
- UniqueLayerC.SubSend -> LowPowerListeningLayerC;
-
-// -------- Low Power Listening
-
-#ifdef LOW_POWER_LISTENING
- components LowPowerListeningLayerC;
- LowPowerListeningLayerC.Config -> RF212ActiveMessageP;
- 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
-
- components PacketLinkLayerC;
- PacketLink = PacketLinkLayerC;
- PacketLinkLayerC.PacketAcknowledgements -> SoftwareAckLayerC;
- PacketLinkLayerC.SubSend -> MessageBufferLayerC;
- PacketLinkLayerC.SubPacket -> TimeStampingLayerC;
-
-// -------- MessageBuffer
-
- components MessageBufferLayerC;
- MessageBufferLayerC.RadioSend -> CollisionAvoidanceLayerC;
- MessageBufferLayerC.RadioReceive -> UniqueLayerC;
- MessageBufferLayerC.RadioState -> RF212DriverLayerC;
- RadioChannel = MessageBufferLayerC;
-
-// -------- UniqueLayer receive part (wired twice)
-
- UniqueLayerC.SubReceive -> CollisionAvoidanceLayerC;
-
-// -------- CollisionAvoidance
-
-#ifdef SLOTTED_MAC
- components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
-#else
- components RandomCollisionLayerC as CollisionAvoidanceLayerC;
-#endif
- CollisionAvoidanceLayerC.Config -> RF212ActiveMessageP;
- CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
- CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
-
-// -------- SoftwareAcknowledgement
-
- components SoftwareAckLayerC;
- SoftwareAckLayerC.Config -> RF212ActiveMessageP;
- SoftwareAckLayerC.SubSend -> CsmaLayerC;
- SoftwareAckLayerC.SubReceive -> RF212DriverLayerC;
- PacketAcknowledgements = SoftwareAckLayerC;
-
-// -------- Carrier Sense
+ components RF212RadioC;
- components new DummyLayerC() as CsmaLayerC;
- CsmaLayerC.Config -> RF212ActiveMessageP;
- CsmaLayerC -> RF212DriverLayerC.RadioSend;
- CsmaLayerC -> RF212DriverLayerC.RadioCCA;
+ SplitControl = RF212RadioC;
-// -------- TimeStamping
+ Ieee154Send = RF212RadioC.Ieee154Send;
+ Ieee154Receive = RF212RadioC.Ieee154Receive;
+ SendNotifier = RF212RadioC.Ieee154Notifier;
- components TimeStampingLayerC;
- TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
- TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
- PacketTimeStampRadio = TimeStampingLayerC;
- PacketTimeStampMilli = TimeStampingLayerC;
+ Packet = RF212RadioC.PacketForIeee154Message;
+ Ieee154Packet = RF212RadioC;
+ RadioSendResource = RF212RadioC;
-// -------- MetadataFlags
+ PacketAcknowledgements = RF212RadioC;
+ LowPowerListening = RF212RadioC;
+ PacketLink = RF212RadioC;
- components MetadataFlagsLayerC;
- MetadataFlagsLayerC.SubPacket -> RF212DriverLayerC;
+ RadioChannel = RF212RadioC;
-// -------- RF212 Driver
+ PacketLinkQuality = RF212RadioC.PacketLinkQuality;
+ PacketTransmitPower = RF212RadioC.PacketTransmitPower;
+ PacketRSSI = RF212RadioC.PacketRSSI;
- components RF212DriverLayerC;
- RF212DriverLayerC.Config -> RF212ActiveMessageP;
- RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
- PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
- PacketLinkQuality = RF212DriverLayerC.PacketLinkQuality;
- PacketRSSI = RF212DriverLayerC.PacketRSSI;
- LocalTimeRadio = RF212DriverLayerC;
+ LocalTimeRadio = RF212RadioC;
+ PacketTimeStampMilli = RF212RadioC;
+ PacketTimeStampRadio = RF212RadioC;
}
--- /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
+ */
+
+#ifndef __RF212RADIO_H__
+#define __RF212RADIO_H__
+
+#include <TinyosNetworkLayer.h>
+#include <Ieee154PacketLayer.h>
+#include <ActiveMessageLayer.h>
+#include <MetadataFlagsLayer.h>
+#include <RF212DriverLayer.h>
+#include <TimeStampingLayer.h>
+#include <LowPowerListeningLayer.h>
+#include <PacketLinkLayer.h>
+
+typedef nx_struct rf212packet_header_t
+{
+ rf212_header_t rf212;
+ ieee154_header_t ieee154;
+#ifndef TFRAMES_ENABLED
+ network_header_t network;
+#endif
+#ifndef IEEE154FRAMES_ENABLED
+ activemessage_header_t am;
+#endif
+} rf212packet_header_t;
+
+typedef nx_struct rf212packet_footer_t
+{
+ // the time stamp is not recorded here, time stamped messaged cannot have max length
+} rf212packet_footer_t;
+
+typedef struct rf212packet_metadata_t
+{
+#ifdef LOW_POWER_LISTENING
+ lpl_metadata_t lpl;
+#endif
+#ifdef PACKET_LINK
+ link_metadata_t link;
+#endif
+ timestamp_metadata_t timestamp;
+ flags_metadata_t flags;
+ rf212_metadata_t rf212;
+} rf212packet_metadata_t;
+
+#endif//__RF212RADIO_H__
--- /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
+ */
+
+#include <RadioConfig.h>
+
+#ifndef TFRAMES_ENABLED
+#define PACKET_LINK
+#endif
+
+configuration RF212RadioC
+{
+ provides
+ {
+ interface SplitControl;
+
+#ifndef IEEE154FRAMES_ENABLED
+ interface AMSend[am_id_t id];
+ interface Receive[am_id_t id];
+ interface Receive as Snoop[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 RadioSendResource[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 RF212RadioP, RadioAlarmC;
+
+#ifdef RADIO_DEBUG
+ components AssertC;
+#endif
+
+ RF212RadioP.Ieee154PacketLayer -> Ieee154PacketLayerC;
+ RF212RadioP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")];
+ RF212RadioP.PacketTimeStamp -> TimeStampingLayerC;
+ RF212RadioP.RF212Packet -> RF212DriverLayerC;
+
+// -------- Active Message
+
+#ifndef IEEE154FRAMES_ENABLED
+ components ActiveMessageLayerC;
+ ActiveMessageLayerC.Config -> RF212RadioP;
+ ActiveMessageLayerC.SubSend -> AutoResourceAcquireLayerC;
+ ActiveMessageLayerC.SubReceive -> TinyosNetworkLayerC.TinyosReceive;
+ ActiveMessageLayerC.SubPacket -> TinyosNetworkLayerC.TinyosPacket;
+
+ AMSend = ActiveMessageLayerC;
+ Receive = ActiveMessageLayerC.Receive;
+ Snoop = ActiveMessageLayerC.Snoop;
+ SendNotifier = ActiveMessageLayerC;
+ AMPacket = ActiveMessageLayerC;
+ PacketForActiveMessage = ActiveMessageLayerC;
+#endif
+
+// -------- Automatic RadioSend Resource
+
+#ifndef IEEE154FRAMES_ENABLED
+#ifndef TFRAMES_ENABLED
+ components new AutoResourceAcquireLayerC();
+ AutoResourceAcquireLayerC.Resource -> RadioSendResourceC.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 RadioSendResourceC;
+ RadioSendResource = RadioSendResourceC;
+
+// -------- 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 -> RF212RadioP;
+ UniqueLayerC.SubSend -> LowPowerListeningLayerC;
+
+// -------- Low Power Listening
+
+#ifdef LOW_POWER_LISTENING
+ #warning "*** USING LOW POWER LISTENING LAYER"
+ components LowPowerListeningLayerC;
+ LowPowerListeningLayerC.Config -> RF212RadioP;
+ 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 -> RF212RadioP;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioSend;
+ TrafficMonitorLayerC -> CollisionAvoidanceLayerC.RadioReceive;
+ TrafficMonitorLayerC -> RF212DriverLayerC.RadioState;
+
+// -------- CollisionAvoidance
+
+#ifdef SLOTTED_MAC
+ components SlottedCollisionLayerC as CollisionAvoidanceLayerC;
+#else
+ components RandomCollisionLayerC as CollisionAvoidanceLayerC;
+#endif
+ CollisionAvoidanceLayerC.Config -> RF212RadioP;
+ CollisionAvoidanceLayerC.SubSend -> SoftwareAckLayerC;
+ CollisionAvoidanceLayerC.SubReceive -> SoftwareAckLayerC;
+
+// -------- SoftwareAcknowledgement
+
+ components SoftwareAckLayerC;
+ SoftwareAckLayerC.Config -> RF212RadioP;
+ SoftwareAckLayerC.SubSend -> CsmaLayerC;
+ SoftwareAckLayerC.SubReceive -> RF212DriverLayerC;
+ PacketAcknowledgements = SoftwareAckLayerC;
+
+// -------- Carrier Sense
+
+ components new DummyLayerC() as CsmaLayerC;
+ CsmaLayerC.Config -> RF212RadioP;
+ CsmaLayerC -> RF212DriverLayerC.RadioSend;
+ CsmaLayerC -> RF212DriverLayerC.RadioCCA;
+
+// -------- TimeStamping
+
+ components TimeStampingLayerC;
+ TimeStampingLayerC.LocalTimeRadio -> RF212DriverLayerC;
+ TimeStampingLayerC.SubPacket -> MetadataFlagsLayerC;
+ PacketTimeStampRadio = TimeStampingLayerC;
+ PacketTimeStampMilli = TimeStampingLayerC;
+
+// -------- MetadataFlags
+
+ components MetadataFlagsLayerC;
+ MetadataFlagsLayerC.SubPacket -> RF212DriverLayerC;
+
+// -------- RF212 Driver
+
+ components RF212DriverLayerC;
+ RF212DriverLayerC.Config -> RF212RadioP;
+ RF212DriverLayerC.PacketTimeStamp -> TimeStampingLayerC;
+ PacketTransmitPower = RF212DriverLayerC.PacketTransmitPower;
+ PacketLinkQuality = RF212DriverLayerC.PacketLinkQuality;
+ PacketRSSI = RF212DriverLayerC.PacketRSSI;
+ LocalTimeRadio = RF212DriverLayerC;
+}
--- /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
+ */
+
+#include <RF212Radio.h>
+#include <RadioConfig.h>
+#include <Tasklet.h>
+
+module RF212RadioP
+{
+ provides
+ {
+ interface RF212DriverConfig;
+ interface SoftwareAckConfig;
+ interface UniqueConfig;
+ interface CsmaConfig;
+ interface TrafficMonitorConfig;
+ interface RandomCollisionConfig;
+ interface SlottedCollisionConfig;
+ interface ActiveMessageConfig;
+ interface DummyConfig;
+
+#ifdef LOW_POWER_LISTENING
+ interface LowPowerListeningConfig;
+#endif
+ }
+
+ uses
+ {
+ interface Ieee154PacketLayer;
+ interface RadioAlarm;
+ interface RadioPacket as RF212Packet;
+
+ interface PacketTimeStamp<TRadio, uint32_t>;
+ }
+}
+
+implementation
+{
+
+/*----------------- RF212DriverConfig -----------------*/
+
+ async command uint8_t RF212DriverConfig.headerLength(message_t* msg)
+ {
+ return offsetof(message_t, data) - sizeof(rf212packet_header_t);
+ }
+
+ async command uint8_t RF212DriverConfig.maxPayloadLength()
+ {
+ return sizeof(rf212packet_header_t) + TOSH_DATA_LENGTH;
+ }
+
+ async command uint8_t RF212DriverConfig.metadataLength(message_t* msg)
+ {
+ return 0;
+ }
+
+ async command uint8_t RF212DriverConfig.headerPreloadLength()
+ {
+ // we need the fcf, dsn, destpan and dest
+ return 7;
+ }
+
+ async command bool RF212DriverConfig.requiresRssiCca(message_t* msg)
+ {
+ return call Ieee154PacketLayer.isDataFrame(msg);
+ }
+
+/*----------------- SoftwareAckConfig -----------------*/
+
+ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
+ {
+ return call Ieee154PacketLayer.requiresAckWait(msg);
+ }
+
+ async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
+ {
+ return call Ieee154PacketLayer.isAckFrame(msg);
+ }
+
+ async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
+ {
+ return call Ieee154PacketLayer.verifyAckReply(data, ack);
+ }
+
+ async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
+ {
+ call Ieee154PacketLayer.setAckRequired(msg, ack);
+ }
+
+ async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
+ {
+ return call Ieee154PacketLayer.requiresAckReply(msg);
+ }
+
+ async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
+ {
+ call Ieee154PacketLayer.createAckReply(data, ack);
+ }
+
+#ifndef SOFTWAREACK_TIMEOUT
+#define SOFTWAREACK_TIMEOUT 1000
+#endif
+
+ async command uint16_t SoftwareAckConfig.getAckTimeout()
+ {
+ return (uint16_t)(SOFTWAREACK_TIMEOUT * RADIO_ALARM_MICROSEC);
+ }
+
+ tasklet_async command void SoftwareAckConfig.reportChannelError()
+ {
+#ifdef TRAFFIC_MONITOR
+ signal TrafficMonitorConfig.channelError();
+#endif
+ }
+
+/*----------------- UniqueConfig -----------------*/
+
+ async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getDSN(msg);
+ }
+
+ async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
+ {
+ call Ieee154PacketLayer.setDSN(msg, dsn);
+ }
+
+ async command am_addr_t UniqueConfig.getSender(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getSrcAddr(msg);
+ }
+
+ tasklet_async command void UniqueConfig.reportChannelError()
+ {
+#ifdef TRAFFIC_MONITOR
+ signal TrafficMonitorConfig.channelError();
+#endif
+ }
+
+/*----------------- ActiveMessageConfig -----------------*/
+
+ command am_addr_t ActiveMessageConfig.destination(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getDestAddr(msg);
+ }
+
+ command void ActiveMessageConfig.setDestination(message_t* msg, am_addr_t addr)
+ {
+ call Ieee154PacketLayer.setDestAddr(msg, addr);
+ }
+
+ command am_addr_t ActiveMessageConfig.source(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getSrcAddr(msg);
+ }
+
+ command void ActiveMessageConfig.setSource(message_t* msg, am_addr_t addr)
+ {
+ call Ieee154PacketLayer.setSrcAddr(msg, addr);
+ }
+
+ command am_group_t ActiveMessageConfig.group(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getDestPan(msg);
+ }
+
+ command void ActiveMessageConfig.setGroup(message_t* msg, am_group_t grp)
+ {
+ call Ieee154PacketLayer.setDestPan(msg, grp);
+ }
+
+/*----------------- CsmaConfig -----------------*/
+
+ async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg)
+ {
+ return call Ieee154PacketLayer.isDataFrame(msg);
+ }
+
+/*----------------- TrafficMonitorConfig -----------------*/
+
+ enum
+ {
+ TRAFFIC_UPDATE_PERIOD = 100, // in milliseconds
+ TRAFFIC_MAX_BYTES = (uint16_t)(TRAFFIC_UPDATE_PERIOD * 1000UL / 32), // 3125
+ };
+
+ async command uint16_t TrafficMonitorConfig.getUpdatePeriod()
+ {
+ return TRAFFIC_UPDATE_PERIOD;
+ }
+
+ async command uint16_t TrafficMonitorConfig.getChannelTime(message_t* msg)
+ {
+ /* We count in bytes, one byte is 32 microsecond. We are conservative here.
+ *
+ * pure airtime: preable (4 bytes), SFD (1 byte), length (1 byte), payload + CRC (len bytes)
+ * frame separation: 5-10 bytes
+ * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation
+ */
+
+ uint8_t len = call RF212Packet.payloadLength(msg);
+ return call Ieee154PacketLayer.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10;
+ }
+
+ async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getSrcAddr(msg);
+ }
+
+/*----------------- RandomCollisionConfig -----------------*/
+
+ /*
+ * We try to use the same values as in CC2420
+ *
+ * CC2420_MIN_BACKOFF = 10 jiffies = 320 microsec
+ * CC2420_BACKOFF_PERIOD = 10 jiffies
+ * initial backoff = 0x1F * CC2420_BACKOFF_PERIOD = 310 jiffies = 9920 microsec
+ * congestion backoff = 0x7 * CC2420_BACKOFF_PERIOD = 70 jiffies = 2240 microsec
+ */
+
+ async command uint16_t RandomCollisionConfig.getMinimumBackoff()
+ {
+ return (uint16_t)(320 * RADIO_ALARM_MICROSEC);
+ }
+
+ async command uint16_t RandomCollisionConfig.getInitialBackoff(message_t* msg)
+ {
+ return (uint16_t)(9920 * RADIO_ALARM_MICROSEC);
+ }
+
+ async command uint16_t RandomCollisionConfig.getCongestionBackoff(message_t* msg)
+ {
+ return (uint16_t)(2240 * RADIO_ALARM_MICROSEC);
+ }
+
+ async command uint16_t RandomCollisionConfig.getTransmitBarrier(message_t* msg)
+ {
+ uint16_t time;
+
+ // TODO: maybe we should use the embedded timestamp of the message
+ time = call RadioAlarm.getNow();
+
+ // estimated response time (download the message, etc) is 5-8 bytes
+ if( call Ieee154PacketLayer.requiresAckReply(msg) )
+ time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC);
+ else
+ time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC);
+
+ return time;
+ }
+
+ tasklet_async event void RadioAlarm.fired()
+ {
+ }
+
+/*----------------- SlottedCollisionConfig -----------------*/
+
+ async command uint16_t SlottedCollisionConfig.getInitialDelay()
+ {
+ return 300;
+ }
+
+ async command uint8_t SlottedCollisionConfig.getScheduleExponent()
+ {
+ return 1 + RADIO_ALARM_MILLI_EXP;
+ }
+
+ async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
+ {
+ // TODO: check if the timestamp is correct
+ return call PacketTimeStamp.timestamp(msg);
+ }
+
+ async command uint16_t SlottedCollisionConfig.getCollisionWindowStart(message_t* msg)
+ {
+ // the preamble (4 bytes), SFD (1 byte), plus two extra for safety
+ return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
+ }
+
+ async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
+ {
+ return (uint16_t)(2 * 7 * 32 * RADIO_ALARM_MICROSEC);
+ }
+
+/*----------------- Dummy -----------------*/
+
+ async command void DummyConfig.nothing()
+ {
+ }
+
+/*----------------- LowPowerListening -----------------*/
+
+#ifdef LOW_POWER_LISTENING
+
+ async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
+ {
+ return call Ieee154PacketLayer.getAckRequired(msg);
+ }
+
+#endif
+
+}