From: mmaroti Date: Sun, 29 Mar 2009 21:12:06 +0000 (+0000) Subject: rename IEEE154Packet components to avoid a clash with blip X-Git-Tag: rc_6_tinyos_2_1_1~437 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=6ffe55d08614a3c92650580514ee29d4a7112e6d rename IEEE154Packet components to avoid a clash with blip --- diff --git a/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc b/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc index 02b301ed..cf83fb44 100644 --- a/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc +++ b/apps/tests/rf230/RF230Sniffer/RF230SnifferC.nc @@ -27,7 +27,7 @@ configuration RF230SnifferC implementation { - components RF230SnifferP, MainC, SerialActiveMessageC, RF230DriverLayerC, RF230ActiveMessageP, IEEE154PacketC, AssertC; + components RF230SnifferP, MainC, SerialActiveMessageC, RF230DriverLayerC, RF230ActiveMessageP, IEEE154Packet2C, AssertC; RF230SnifferP.Boot -> MainC; RF230SnifferP.SplitControl -> SerialActiveMessageC; @@ -35,7 +35,7 @@ implementation RF230DriverLayerC.RF230DriverConfig -> RF230ActiveMessageP; - RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC; + RF230ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; // just to avoid a timer compilation bug components new TimerMilliC(); diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc index 2cfd690e..5069218d 100644 --- a/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc +++ b/tos/chips/rf2xx/layers/IEEE154NetworkLayerC.nc @@ -39,7 +39,7 @@ configuration IEEE154NetworkLayerC implementation { - components IEEE154NetworkLayerP, IEEE154PacketC; + components IEEE154NetworkLayerP, IEEE154Packet2C; SplitControl = SubControl; @@ -49,5 +49,5 @@ implementation SubSend = IEEE154NetworkLayerP; SubReceive = IEEE154NetworkLayerP; - IEEE154NetworkLayerP.IEEE154Packet -> IEEE154PacketC; + IEEE154NetworkLayerP.IEEE154Packet2 -> IEEE154Packet2C; } diff --git a/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc b/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc index f4abf636..4771f688 100644 --- a/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc +++ b/tos/chips/rf2xx/layers/IEEE154NetworkLayerP.nc @@ -35,7 +35,7 @@ module IEEE154NetworkLayerP interface Send as SubSend; interface Receive as SubReceive; - interface IEEE154Packet; + interface IEEE154Packet2; } } @@ -47,7 +47,7 @@ implementation command error_t Send.send(message_t* msg, uint8_t len) { - call IEEE154Packet.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID); + call IEEE154Packet2.set6LowPan(msg, TINYOS_6LOWPAN_NETWORK_ID); return call SubSend.send(msg, len); } @@ -73,7 +73,7 @@ implementation event message_t *SubReceive.receive(message_t *msg, void *payload, uint8_t len) { - uint8_t network = call IEEE154Packet.get6LowPan(msg); + uint8_t network = call IEEE154Packet2.get6LowPan(msg); if( network == TINYOS_6LOWPAN_NETWORK_ID ) return signal Receive.receive(msg, payload, len); else diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc index 6a79f853..d7b0f3aa 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageC.nc @@ -50,13 +50,13 @@ configuration RF212ActiveMessageC implementation { - components RF212ActiveMessageP, RF212PacketC, IEEE154PacketC, RadioAlarmC; + components RF212ActiveMessageP, RF212PacketC, IEEE154Packet2C, RadioAlarmC; #ifdef RADIO_DEBUG components AssertC; #endif - RF212ActiveMessageP.IEEE154Packet -> IEEE154PacketC; + RF212ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; RF212ActiveMessageP.Packet -> RF212PacketC; RF212ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; @@ -100,7 +100,7 @@ implementation Snoop = ActiveMessageLayerC.Snoop; ActiveMessageLayerC.Config -> RF212ActiveMessageP; - ActiveMessageLayerC.AMPacket -> IEEE154PacketC; + ActiveMessageLayerC.AMPacket -> IEEE154Packet2C; ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; @@ -116,7 +116,7 @@ implementation LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; #ifdef LOW_POWER_LISTENING LowPowerListeningLayerC.PacketSleepInterval -> RF212PacketC; - LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC; + LowPowerListeningLayerC.IEEE154Packet2 -> IEEE154Packet2C; LowPowerListeningLayerC.PacketAcknowledgements -> RF212PacketC; #endif diff --git a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc index 5e8104fd..f7332b29 100644 --- a/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf212/RF212ActiveMessageP.nc @@ -42,7 +42,7 @@ module RF212ActiveMessageP uses { - interface IEEE154Packet; + interface IEEE154Packet2; interface Packet; interface RadioAlarm; } @@ -54,17 +54,17 @@ implementation async command uint8_t RF212DriverConfig.getLength(message_t* msg) { - return call IEEE154Packet.getLength(msg); + return call IEEE154Packet2.getLength(msg); } async command void RF212DriverConfig.setLength(message_t* msg, uint8_t len) { - call IEEE154Packet.setLength(msg, len); + call IEEE154Packet2.setLength(msg, len); } async command uint8_t* RF212DriverConfig.getPayload(message_t* msg) { - return ((uint8_t*)(call IEEE154Packet.getHeader(msg))) + 1; + return ((uint8_t*)(call IEEE154Packet2.getHeader(msg))) + 1; } inline rf212packet_metadata_t* getMeta(message_t* msg) @@ -86,34 +86,34 @@ implementation async command bool RF212DriverConfig.requiresRssiCca(message_t* msg) { - return call IEEE154Packet.isDataFrame(msg); + return call IEEE154Packet2.isDataFrame(msg); } /*----------------- SoftwareAckConfig -----------------*/ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg) { - return call IEEE154Packet.requiresAckWait(msg); + return call IEEE154Packet2.requiresAckWait(msg); } async command bool SoftwareAckConfig.isAckPacket(message_t* msg) { - return call IEEE154Packet.isAckFrame(msg); + return call IEEE154Packet2.isAckFrame(msg); } async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack) { - return call IEEE154Packet.verifyAckReply(data, ack); + return call IEEE154Packet2.verifyAckReply(data, ack); } async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) { - return call IEEE154Packet.requiresAckReply(msg); + return call IEEE154Packet2.requiresAckReply(msg); } async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) { - call IEEE154Packet.createAckReply(data, ack); + call IEEE154Packet2.createAckReply(data, ack); } async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked) @@ -138,17 +138,17 @@ implementation async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg) { - return call IEEE154Packet.getDSN(msg); + return call IEEE154Packet2.getDSN(msg); } async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn) { - call IEEE154Packet.setDSN(msg, dsn); + call IEEE154Packet2.setDSN(msg, dsn); } async command am_addr_t UniqueConfig.getSender(message_t* msg) { - return call IEEE154Packet.getSrcAddr(msg); + return call IEEE154Packet2.getSrcAddr(msg); } tasklet_async command void UniqueConfig.reportChannelError() @@ -161,7 +161,7 @@ implementation command error_t ActiveMessageConfig.checkPacket(message_t* msg) { // the user forgot to call clear, we should return EINVAL - if( ! call IEEE154Packet.isDataFrame(msg) ) + if( ! call IEEE154Packet2.isDataFrame(msg) ) call Packet.clear(msg); return SUCCESS; @@ -171,7 +171,7 @@ implementation async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) { - return call IEEE154Packet.isDataFrame(msg); + return call IEEE154Packet2.isDataFrame(msg); } /*----------------- TrafficMonitorConfig -----------------*/ @@ -196,13 +196,13 @@ implementation * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation */ - uint8_t len = call IEEE154Packet.getLength(msg); - return call IEEE154Packet.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; + uint8_t len = call IEEE154Packet2.getLength(msg); + return call IEEE154Packet2.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg) { - return call IEEE154Packet.getSrcAddr(msg); + return call IEEE154Packet2.getSrcAddr(msg); } tasklet_async command void TrafficMonitorConfig.timerTick() @@ -244,7 +244,7 @@ implementation time = call RadioAlarm.getNow(); // estimated response time (download the message, etc) is 5-8 bytes - if( call IEEE154Packet.requiresAckReply(msg) ) + if( call IEEE154Packet2.requiresAckReply(msg) ) time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC); else time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC); diff --git a/tos/chips/rf2xx/rf212/RF212Packet.h b/tos/chips/rf2xx/rf212/RF212Packet.h index 5b7a68b9..15866b7a 100644 --- a/tos/chips/rf2xx/rf212/RF212Packet.h +++ b/tos/chips/rf2xx/rf212/RF212Packet.h @@ -24,7 +24,7 @@ #ifndef __RF212PACKET_H__ #define __RF212PACKET_H__ -#include +#include typedef ieee154_header_t rf212packet_header_t; diff --git a/tos/chips/rf2xx/rf212/RF212PacketC.nc b/tos/chips/rf2xx/rf212/RF212PacketC.nc index 68eb9b29..5a53cf42 100644 --- a/tos/chips/rf2xx/rf212/RF212PacketC.nc +++ b/tos/chips/rf2xx/rf212/RF212PacketC.nc @@ -41,14 +41,14 @@ configuration RF212PacketC implementation { - components RF212PacketP, IEEE154PacketC, LocalTimeMicroC, LocalTimeMilliC; + components RF212PacketP, IEEE154Packet2C, LocalTimeMicroC, LocalTimeMilliC; - RF212PacketP.IEEE154Packet -> IEEE154PacketC; + RF212PacketP.IEEE154Packet2 -> IEEE154Packet2C; RF212PacketP.LocalTimeRadio -> LocalTimeMicroC; RF212PacketP.LocalTimeMilli -> LocalTimeMilliC; Packet = RF212PacketP; - AMPacket = IEEE154PacketC; + AMPacket = IEEE154Packet2C; PacketAcknowledgements = RF212PacketP; PacketLinkQuality = RF212PacketP.PacketLinkQuality; diff --git a/tos/chips/rf2xx/rf212/RF212PacketP.nc b/tos/chips/rf2xx/rf212/RF212PacketP.nc index 0fb8ceae..3641c1bd 100644 --- a/tos/chips/rf2xx/rf212/RF212PacketP.nc +++ b/tos/chips/rf2xx/rf212/RF212PacketP.nc @@ -43,7 +43,7 @@ module RF212PacketP uses { - interface IEEE154Packet; + interface IEEE154Packet2; interface LocalTime as LocalTimeRadio; interface LocalTime as LocalTimeMilli; @@ -68,19 +68,19 @@ implementation command void Packet.clear(message_t* msg) { - call IEEE154Packet.createDataFrame(msg); + call IEEE154Packet2.createDataFrame(msg); getMeta(msg)->flags = RF212PACKET_CLEAR_METADATA; } inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) { - call IEEE154Packet.setLength(msg, len + PACKET_LENGTH_INCREASE); + call IEEE154Packet2.setLength(msg, len + PACKET_LENGTH_INCREASE); } inline command uint8_t Packet.payloadLength(message_t* msg) { - return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE; + return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE; } inline command uint8_t Packet.maxPayloadLength() @@ -100,14 +100,14 @@ implementation async command error_t PacketAcknowledgements.requestAck(message_t* msg) { - call IEEE154Packet.setAckRequired(msg, TRUE); + call IEEE154Packet2.setAckRequired(msg, TRUE); return SUCCESS; } async command error_t PacketAcknowledgements.noAck(message_t* msg) { - call IEEE154Packet.setAckRequired(msg, FALSE); + call IEEE154Packet2.setAckRequired(msg, FALSE); return SUCCESS; } @@ -244,7 +244,7 @@ implementation async command uint8_t PacketTimeSyncOffset.get(message_t* msg) { - return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); + return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); } async command void PacketTimeSyncOffset.clear(message_t* msg) diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc index 46c2f575..a6ecda76 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageC.nc @@ -50,13 +50,13 @@ configuration RF230ActiveMessageC implementation { - components RF230ActiveMessageP, RF230PacketC, IEEE154PacketC, RadioAlarmC; + components RF230ActiveMessageP, RF230PacketC, IEEE154Packet2C, RadioAlarmC; #ifdef RADIO_DEBUG components AssertC; #endif - RF230ActiveMessageP.IEEE154Packet -> IEEE154PacketC; + RF230ActiveMessageP.IEEE154Packet2 -> IEEE154Packet2C; RF230ActiveMessageP.Packet -> RF230PacketC; RF230ActiveMessageP.RadioAlarm -> RadioAlarmC.RadioAlarm[unique("RadioAlarm")]; @@ -100,7 +100,7 @@ implementation Snoop = ActiveMessageLayerC.Snoop; ActiveMessageLayerC.Config -> RF230ActiveMessageP; - ActiveMessageLayerC.AMPacket -> IEEE154PacketC; + ActiveMessageLayerC.AMPacket -> IEEE154Packet2C; ActiveMessageLayerC.SubSend -> IEEE154NetworkLayerC; ActiveMessageLayerC.SubReceive -> IEEE154NetworkLayerC; @@ -116,7 +116,7 @@ implementation LowPowerListeningLayerC.SubReceive -> MessageBufferLayerC; #ifdef LOW_POWER_LISTENING LowPowerListeningLayerC.PacketSleepInterval -> RF230PacketC; - LowPowerListeningLayerC.IEEE154Packet -> IEEE154PacketC; + LowPowerListeningLayerC.IEEE154Packet2 -> IEEE154Packet2C; LowPowerListeningLayerC.PacketAcknowledgements -> RF230PacketC; #endif diff --git a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc index 61473a4c..9c8044cd 100644 --- a/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc +++ b/tos/chips/rf2xx/rf230/RF230ActiveMessageP.nc @@ -42,7 +42,7 @@ module RF230ActiveMessageP uses { - interface IEEE154Packet; + interface IEEE154Packet2; interface Packet; interface RadioAlarm; } @@ -54,17 +54,17 @@ implementation async command uint8_t RF230DriverConfig.getLength(message_t* msg) { - return call IEEE154Packet.getLength(msg); + return call IEEE154Packet2.getLength(msg); } async command void RF230DriverConfig.setLength(message_t* msg, uint8_t len) { - call IEEE154Packet.setLength(msg, len); + call IEEE154Packet2.setLength(msg, len); } async command uint8_t* RF230DriverConfig.getPayload(message_t* msg) { - return ((uint8_t*)(call IEEE154Packet.getHeader(msg))) + 1; + return ((uint8_t*)(call IEEE154Packet2.getHeader(msg))) + 1; } inline rf230packet_metadata_t* getMeta(message_t* msg) @@ -86,34 +86,34 @@ implementation async command bool RF230DriverConfig.requiresRssiCca(message_t* msg) { - return call IEEE154Packet.isDataFrame(msg); + return call IEEE154Packet2.isDataFrame(msg); } /*----------------- SoftwareAckConfig -----------------*/ async command bool SoftwareAckConfig.requiresAckWait(message_t* msg) { - return call IEEE154Packet.requiresAckWait(msg); + return call IEEE154Packet2.requiresAckWait(msg); } async command bool SoftwareAckConfig.isAckPacket(message_t* msg) { - return call IEEE154Packet.isAckFrame(msg); + return call IEEE154Packet2.isAckFrame(msg); } async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack) { - return call IEEE154Packet.verifyAckReply(data, ack); + return call IEEE154Packet2.verifyAckReply(data, ack); } async command bool SoftwareAckConfig.requiresAckReply(message_t* msg) { - return call IEEE154Packet.requiresAckReply(msg); + return call IEEE154Packet2.requiresAckReply(msg); } async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack) { - call IEEE154Packet.createAckReply(data, ack); + call IEEE154Packet2.createAckReply(data, ack); } async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked) @@ -138,17 +138,17 @@ implementation async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg) { - return call IEEE154Packet.getDSN(msg); + return call IEEE154Packet2.getDSN(msg); } async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn) { - call IEEE154Packet.setDSN(msg, dsn); + call IEEE154Packet2.setDSN(msg, dsn); } async command am_addr_t UniqueConfig.getSender(message_t* msg) { - return call IEEE154Packet.getSrcAddr(msg); + return call IEEE154Packet2.getSrcAddr(msg); } tasklet_async command void UniqueConfig.reportChannelError() @@ -161,7 +161,7 @@ implementation command error_t ActiveMessageConfig.checkPacket(message_t* msg) { // the user forgot to call clear, we should return EINVAL - if( ! call IEEE154Packet.isDataFrame(msg) ) + if( ! call IEEE154Packet2.isDataFrame(msg) ) call Packet.clear(msg); return SUCCESS; @@ -171,7 +171,7 @@ implementation async command bool CsmaConfig.requiresSoftwareCCA(message_t* msg) { - return call IEEE154Packet.isDataFrame(msg); + return call IEEE154Packet2.isDataFrame(msg); } /*----------------- TrafficMonitorConfig -----------------*/ @@ -196,13 +196,13 @@ implementation * ack required: 8-16 byte separation, 11 bytes airtime, 5-10 bytes separation */ - uint8_t len = call IEEE154Packet.getLength(msg); - return call IEEE154Packet.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; + uint8_t len = call IEEE154Packet2.getLength(msg); + return call IEEE154Packet2.getAckRequired(msg) ? len + 6 + 16 + 11 + 10 : len + 6 + 10; } async command am_addr_t TrafficMonitorConfig.getSender(message_t* msg) { - return call IEEE154Packet.getSrcAddr(msg); + return call IEEE154Packet2.getSrcAddr(msg); } tasklet_async command void TrafficMonitorConfig.timerTick() @@ -244,7 +244,7 @@ implementation time = call RadioAlarm.getNow(); // estimated response time (download the message, etc) is 5-8 bytes - if( call IEEE154Packet.requiresAckReply(msg) ) + if( call IEEE154Packet2.requiresAckReply(msg) ) time += (uint16_t)(32 * (-5 + 16 + 11 + 5) * RADIO_ALARM_MICROSEC); else time += (uint16_t)(32 * (-5 + 5) * RADIO_ALARM_MICROSEC); diff --git a/tos/chips/rf2xx/rf230/RF230Packet.h b/tos/chips/rf2xx/rf230/RF230Packet.h index f12e3e5b..5e3e8bd7 100644 --- a/tos/chips/rf2xx/rf230/RF230Packet.h +++ b/tos/chips/rf2xx/rf230/RF230Packet.h @@ -24,7 +24,7 @@ #ifndef __RF230PACKET_H__ #define __RF230PACKET_H__ -#include +#include typedef ieee154_header_t rf230packet_header_t; diff --git a/tos/chips/rf2xx/rf230/RF230PacketC.nc b/tos/chips/rf2xx/rf230/RF230PacketC.nc index 9d09b314..23115e83 100644 --- a/tos/chips/rf2xx/rf230/RF230PacketC.nc +++ b/tos/chips/rf2xx/rf230/RF230PacketC.nc @@ -41,14 +41,14 @@ configuration RF230PacketC implementation { - components RF230PacketP, IEEE154PacketC, LocalTimeMicroC, LocalTimeMilliC; + components RF230PacketP, IEEE154Packet2C, LocalTimeMicroC, LocalTimeMilliC; - RF230PacketP.IEEE154Packet -> IEEE154PacketC; + RF230PacketP.IEEE154Packet2 -> IEEE154Packet2C; RF230PacketP.LocalTimeRadio -> LocalTimeMicroC; RF230PacketP.LocalTimeMilli -> LocalTimeMilliC; Packet = RF230PacketP; - AMPacket = IEEE154PacketC; + AMPacket = IEEE154Packet2C; PacketAcknowledgements = RF230PacketP; PacketLinkQuality = RF230PacketP.PacketLinkQuality; diff --git a/tos/chips/rf2xx/rf230/RF230PacketP.nc b/tos/chips/rf2xx/rf230/RF230PacketP.nc index 383cad78..45b94bf6 100644 --- a/tos/chips/rf2xx/rf230/RF230PacketP.nc +++ b/tos/chips/rf2xx/rf230/RF230PacketP.nc @@ -43,7 +43,7 @@ module RF230PacketP uses { - interface IEEE154Packet; + interface IEEE154Packet2; interface LocalTime as LocalTimeRadio; interface LocalTime as LocalTimeMilli; @@ -68,19 +68,19 @@ implementation command void Packet.clear(message_t* msg) { - call IEEE154Packet.createDataFrame(msg); + call IEEE154Packet2.createDataFrame(msg); getMeta(msg)->flags = RF230PACKET_CLEAR_METADATA; } inline command void Packet.setPayloadLength(message_t* msg, uint8_t len) { - call IEEE154Packet.setLength(msg, len + PACKET_LENGTH_INCREASE); + call IEEE154Packet2.setLength(msg, len + PACKET_LENGTH_INCREASE); } inline command uint8_t Packet.payloadLength(message_t* msg) { - return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE; + return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE; } inline command uint8_t Packet.maxPayloadLength() @@ -100,14 +100,14 @@ implementation async command error_t PacketAcknowledgements.requestAck(message_t* msg) { - call IEEE154Packet.setAckRequired(msg, TRUE); + call IEEE154Packet2.setAckRequired(msg, TRUE); return SUCCESS; } async command error_t PacketAcknowledgements.noAck(message_t* msg) { - call IEEE154Packet.setAckRequired(msg, FALSE); + call IEEE154Packet2.setAckRequired(msg, FALSE); return SUCCESS; } @@ -244,7 +244,7 @@ implementation async command uint8_t PacketTimeSyncOffset.get(message_t* msg) { - return call IEEE154Packet.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); + return call IEEE154Packet2.getLength(msg) - PACKET_LENGTH_INCREASE - sizeof(timesync_absolute_t); } async command void PacketTimeSyncOffset.clear(message_t* msg) diff --git a/tos/chips/rf2xx/util/IEEE154Packet.h b/tos/chips/rf2xx/util/IEEE154Packet.h deleted file mode 100644 index 62fe16b0..00000000 --- a/tos/chips/rf2xx/util/IEEE154Packet.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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 __IEEE154PACKET_H__ -#define __IEEE154PACKET_H__ - -typedef nx_struct ieee154_header_t -{ - nxle_uint8_t length; - nxle_uint16_t fcf; - nxle_uint8_t dsn; - nxle_uint16_t destpan; - nxle_uint16_t dest; - nxle_uint16_t src; - -// I-Frame 6LowPAN interoperability byte -#ifndef TFRAMES_ENABLED - nxle_uint8_t network; -#endif - - nxle_uint8_t type; -} ieee154_header_t; - -// the actual radio driver might not use this -typedef nx_struct ieee154_footer_t -{ - nxle_uint16_t crc; -} ieee154_footer_t; - -enum ieee154_fcf_enums { - IEEE154_FCF_FRAME_TYPE = 0, - IEEE154_FCF_SECURITY_ENABLED = 3, - IEEE154_FCF_FRAME_PENDING = 4, - IEEE154_FCF_ACK_REQ = 5, - IEEE154_FCF_INTRAPAN = 6, - IEEE154_FCF_DEST_ADDR_MODE = 10, - IEEE154_FCF_SRC_ADDR_MODE = 14, -}; - -enum ieee154_fcf_type_enums { - IEEE154_TYPE_BEACON = 0, - IEEE154_TYPE_DATA = 1, - IEEE154_TYPE_ACK = 2, - IEEE154_TYPE_MAC_CMD = 3, - IEEE154_TYPE_MASK = 7, -}; - -enum iee154_fcf_addr_mode_enums { - IEEE154_ADDR_NONE = 0, - IEEE154_ADDR_SHORT = 2, - IEEE154_ADDR_EXT = 3, - IEEE154_ADDR_MASK = 3, -}; - -#endif//__IEEE154PACKET_H__ diff --git a/tos/chips/rf2xx/util/IEEE154Packet.nc b/tos/chips/rf2xx/util/IEEE154Packet.nc deleted file mode 100644 index fd171743..00000000 --- a/tos/chips/rf2xx/util/IEEE154Packet.nc +++ /dev/null @@ -1,197 +0,0 @@ -/* - * 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 -#include - -/** - * This interface encapsulates IEEE 802.15.4 intrapan data frames with - * 16-bit destination pan, source and destination addresses. It also - * supports 6LowPan interoperability mode, and acknowledgement frames. - * Note, that this interface does not support the CRC-16 value, which - * should be verified before the data can be trusted. - */ -interface IEEE154Packet -{ - /** - * Returns the IEEE 802.15.4 header including the length field. - */ - async command ieee154_header_t* getHeader(message_t* msg); - - /** - * Returns the raw value (unadjusted) of the length field - */ - async command uint8_t getLength(message_t* msg); - - /** - * Sets the length field - */ - async command void setLength(message_t* msg, uint8_t length); - - /** - * Returns the frame control field. This method should not be used, - * isDataFrame and isAckFrame should be used instead. - */ - async command uint16_t getFCF(message_t* msg); - - /** - * Sets the frame control field. This method should not be used, - * createDataFrame and createAckFrame should be used instead. - */ - async command void setFCF(message_t* msg, uint16_t fcf); - - /** - * Returns TRUE if the message is a data frame supported by - * this interface (based on the value of the FCF). - */ - async command bool isDataFrame(message_t* msg); - - /** - * Sets the FCF to create a data frame supported by this interface. - * You may call setAckRequired and setFramePending commands after this. - */ - async command void createDataFrame(message_t* msg); - - /** - * Returns TRUE if the message is an acknowledgement frame supported - * by this interface (based on the value of the FCF). - */ - async command bool isAckFrame(message_t* msg); - - /** - * Sets the FCF to create an acknowledgement frame supported by - * this interface. You may call setFramePending after this. - */ - async command void createAckFrame(message_t* msg); - - /** - * Creates an acknowledgement packet for the given data packet. - * This also sets the DSN value. The data message must be a - * data frame, the ack message will be overwritten. - */ - async command void createAckReply(message_t* data, message_t* ack); - - /** - * Returns TRUE if the acknowledgement packet corresponds to the - * data packet. The data message must be a data packet. - */ - async command bool verifyAckReply(message_t* data, message_t* ack); - - /** - * Returns TRUE if the ACK required field is set in the FCF. - */ - async command bool getAckRequired(message_t* msg); - - /** - * Sets the ACK required field in the FCF, should never be set - * for acknowledgement frames. - */ - async command void setAckRequired(message_t* msg, bool ack); - - /** - * Returns TRUE if the frame pending field is set in the FCF. - */ - async command bool getFramePending(message_t* msg); - - /** - * Sets the frame pending field in the FCF. - */ - async command void setFramePending(message_t* msg, bool pending); - - /** - * Returns the data sequence number - */ - async command uint8_t getDSN(message_t* msg); - - /** - * Sets the data sequence number - */ - async command void setDSN(message_t* msg, uint8_t dsn); - - /** - * returns the destination PAN id, values <= 255 are tinyos groups, - * valid only for data frames - */ - async command uint16_t getDestPan(message_t* msg); - - /** - * Sets the destination PAN id, valid only for data frames - */ - async command void setDestPan(message_t* msg, uint16_t pan); - - /** - * Returns the destination address, valid only for data frames - */ - async command uint16_t getDestAddr(message_t* msg); - - /** - * Sets the destination address, valid only for data frames - */ - async command void setDestAddr(message_t* msg, uint16_t addr); - - /** - * Returns the source address, valid only for data frames - */ - async command uint16_t getSrcAddr(message_t* msg); - - /** - * Sets the source address, valid only for data frames - */ - async command void setSrcAddr(message_t* msg, uint16_t addr); - -#ifndef TFRAMES_ENABLED - - /** - * Returns the value of the 6LowPan network field. - */ - async command uint8_t get6LowPan(message_t* msg); - - /** - * Sets the value of the 6LowPan network field. - */ - async command void set6LowPan(message_t* msg, uint8_t network); - -#endif - - /** - * Returns the active message type of the message - */ - async command am_id_t getType(message_t* msg); - - /** - * Sets the active message type - */ - async command void setType(message_t* msg, am_id_t type); - - /** - * Returns TRUE if the packet is a data packet, the ACK_REQ field - * is set and the destination address is not the broadcast address. - */ - async command bool requiresAckWait(message_t* msg); - - /** - * Returns TRUE if the packet is a data packet, the ACK_REQ field - * is set and the destionation address is this node. - */ - async command bool requiresAckReply(message_t* msg); -} diff --git a/tos/chips/rf2xx/util/IEEE154Packet2.h b/tos/chips/rf2xx/util/IEEE154Packet2.h new file mode 100644 index 00000000..5c580071 --- /dev/null +++ b/tos/chips/rf2xx/util/IEEE154Packet2.h @@ -0,0 +1,75 @@ +/* + * 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 __IEEE154PACKET2_H__ +#define __IEEE154PACKET2_H__ + +typedef nx_struct ieee154_header_t +{ + nxle_uint8_t length; + nxle_uint16_t fcf; + nxle_uint8_t dsn; + nxle_uint16_t destpan; + nxle_uint16_t dest; + nxle_uint16_t src; + +// I-Frame 6LowPAN interoperability byte +#ifndef TFRAMES_ENABLED + nxle_uint8_t network; +#endif + + nxle_uint8_t type; +} ieee154_header_t; + +// the actual radio driver might not use this +typedef nx_struct ieee154_footer_t +{ + nxle_uint16_t crc; +} ieee154_footer_t; + +enum ieee154_fcf_enums { + IEEE154_FCF_FRAME_TYPE = 0, + IEEE154_FCF_SECURITY_ENABLED = 3, + IEEE154_FCF_FRAME_PENDING = 4, + IEEE154_FCF_ACK_REQ = 5, + IEEE154_FCF_INTRAPAN = 6, + IEEE154_FCF_DEST_ADDR_MODE = 10, + IEEE154_FCF_SRC_ADDR_MODE = 14, +}; + +enum ieee154_fcf_type_enums { + IEEE154_TYPE_BEACON = 0, + IEEE154_TYPE_DATA = 1, + IEEE154_TYPE_ACK = 2, + IEEE154_TYPE_MAC_CMD = 3, + IEEE154_TYPE_MASK = 7, +}; + +enum iee154_fcf_addr_mode_enums { + IEEE154_ADDR_NONE = 0, + IEEE154_ADDR_SHORT = 2, + IEEE154_ADDR_EXT = 3, + IEEE154_ADDR_MASK = 3, +}; + +#endif//__IEEE154PACKET2_H__ diff --git a/tos/chips/rf2xx/util/IEEE154Packet2.nc b/tos/chips/rf2xx/util/IEEE154Packet2.nc new file mode 100644 index 00000000..09579048 --- /dev/null +++ b/tos/chips/rf2xx/util/IEEE154Packet2.nc @@ -0,0 +1,197 @@ +/* + * 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 +#include + +/** + * This interface encapsulates IEEE 802.15.4 intrapan data frames with + * 16-bit destination pan, source and destination addresses. It also + * supports 6LowPan interoperability mode, and acknowledgement frames. + * Note, that this interface does not support the CRC-16 value, which + * should be verified before the data can be trusted. + */ +interface IEEE154Packet2 +{ + /** + * Returns the IEEE 802.15.4 header including the length field. + */ + async command ieee154_header_t* getHeader(message_t* msg); + + /** + * Returns the raw value (unadjusted) of the length field + */ + async command uint8_t getLength(message_t* msg); + + /** + * Sets the length field + */ + async command void setLength(message_t* msg, uint8_t length); + + /** + * Returns the frame control field. This method should not be used, + * isDataFrame and isAckFrame should be used instead. + */ + async command uint16_t getFCF(message_t* msg); + + /** + * Sets the frame control field. This method should not be used, + * createDataFrame and createAckFrame should be used instead. + */ + async command void setFCF(message_t* msg, uint16_t fcf); + + /** + * Returns TRUE if the message is a data frame supported by + * this interface (based on the value of the FCF). + */ + async command bool isDataFrame(message_t* msg); + + /** + * Sets the FCF to create a data frame supported by this interface. + * You may call setAckRequired and setFramePending commands after this. + */ + async command void createDataFrame(message_t* msg); + + /** + * Returns TRUE if the message is an acknowledgement frame supported + * by this interface (based on the value of the FCF). + */ + async command bool isAckFrame(message_t* msg); + + /** + * Sets the FCF to create an acknowledgement frame supported by + * this interface. You may call setFramePending after this. + */ + async command void createAckFrame(message_t* msg); + + /** + * Creates an acknowledgement packet for the given data packet. + * This also sets the DSN value. The data message must be a + * data frame, the ack message will be overwritten. + */ + async command void createAckReply(message_t* data, message_t* ack); + + /** + * Returns TRUE if the acknowledgement packet corresponds to the + * data packet. The data message must be a data packet. + */ + async command bool verifyAckReply(message_t* data, message_t* ack); + + /** + * Returns TRUE if the ACK required field is set in the FCF. + */ + async command bool getAckRequired(message_t* msg); + + /** + * Sets the ACK required field in the FCF, should never be set + * for acknowledgement frames. + */ + async command void setAckRequired(message_t* msg, bool ack); + + /** + * Returns TRUE if the frame pending field is set in the FCF. + */ + async command bool getFramePending(message_t* msg); + + /** + * Sets the frame pending field in the FCF. + */ + async command void setFramePending(message_t* msg, bool pending); + + /** + * Returns the data sequence number + */ + async command uint8_t getDSN(message_t* msg); + + /** + * Sets the data sequence number + */ + async command void setDSN(message_t* msg, uint8_t dsn); + + /** + * returns the destination PAN id, values <= 255 are tinyos groups, + * valid only for data frames + */ + async command uint16_t getDestPan(message_t* msg); + + /** + * Sets the destination PAN id, valid only for data frames + */ + async command void setDestPan(message_t* msg, uint16_t pan); + + /** + * Returns the destination address, valid only for data frames + */ + async command uint16_t getDestAddr(message_t* msg); + + /** + * Sets the destination address, valid only for data frames + */ + async command void setDestAddr(message_t* msg, uint16_t addr); + + /** + * Returns the source address, valid only for data frames + */ + async command uint16_t getSrcAddr(message_t* msg); + + /** + * Sets the source address, valid only for data frames + */ + async command void setSrcAddr(message_t* msg, uint16_t addr); + +#ifndef TFRAMES_ENABLED + + /** + * Returns the value of the 6LowPan network field. + */ + async command uint8_t get6LowPan(message_t* msg); + + /** + * Sets the value of the 6LowPan network field. + */ + async command void set6LowPan(message_t* msg, uint8_t network); + +#endif + + /** + * Returns the active message type of the message + */ + async command am_id_t getType(message_t* msg); + + /** + * Sets the active message type + */ + async command void setType(message_t* msg, am_id_t type); + + /** + * Returns TRUE if the packet is a data packet, the ACK_REQ field + * is set and the destination address is not the broadcast address. + */ + async command bool requiresAckWait(message_t* msg); + + /** + * Returns TRUE if the packet is a data packet, the ACK_REQ field + * is set and the destionation address is this node. + */ + async command bool requiresAckReply(message_t* msg); +} diff --git a/tos/chips/rf2xx/util/IEEE154Packet2C.nc b/tos/chips/rf2xx/util/IEEE154Packet2C.nc new file mode 100644 index 00000000..c2fa14b5 --- /dev/null +++ b/tos/chips/rf2xx/util/IEEE154Packet2C.nc @@ -0,0 +1,40 @@ +/* + * 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 + */ + +configuration IEEE154Packet2C +{ + provides + { + interface IEEE154Packet2; + interface AMPacket; + } +} + +implementation +{ + components IEEE154Packet2P, ActiveMessageAddressC; + IEEE154Packet2P.ActiveMessageAddress -> ActiveMessageAddressC; + + IEEE154Packet2 = IEEE154Packet2P; + AMPacket = IEEE154Packet2P; +} diff --git a/tos/chips/rf2xx/util/IEEE154Packet2P.nc b/tos/chips/rf2xx/util/IEEE154Packet2P.nc new file mode 100644 index 00000000..cb4ca8c1 --- /dev/null +++ b/tos/chips/rf2xx/util/IEEE154Packet2P.nc @@ -0,0 +1,294 @@ +/* + * 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 + +module IEEE154Packet2P +{ + provides + { + interface IEEE154Packet2; + interface AMPacket; + } + + uses interface ActiveMessageAddress; +} + +implementation +{ +/*----------------- IEEE154Packet -----------------*/ + + enum + { + IEEE154_DATA_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE) + | (1 << IEEE154_FCF_INTRAPAN) + | (IEEE154_ADDR_MASK << IEEE154_FCF_DEST_ADDR_MODE) + | (IEEE154_ADDR_MASK << IEEE154_FCF_SRC_ADDR_MODE), + + IEEE154_DATA_FRAME_VALUE = (IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE) + | (1 << IEEE154_FCF_INTRAPAN) + | (IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE) + | (IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE), + + IEEE154_ACK_FRAME_LENGTH = 5, // includes the FCF, DSN and FCS + IEEE154_ACK_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE), + IEEE154_ACK_FRAME_VALUE = (IEEE154_TYPE_ACK << IEEE154_FCF_FRAME_TYPE), + }; + + inline ieee154_header_t* getHeader(message_t* msg) + { + return (ieee154_header_t*)(msg->data - sizeof(ieee154_header_t)); + } + + inline async command ieee154_header_t* IEEE154Packet2.getHeader(message_t* msg) + { + return getHeader(msg); + } + + inline async command uint8_t IEEE154Packet2.getLength(message_t* msg) + { + return getHeader(msg)->length; + } + + inline async command void IEEE154Packet2.setLength(message_t* msg, uint8_t length) + { + getHeader(msg)->length = length; + } + + inline async command uint16_t IEEE154Packet2.getFCF(message_t* msg) + { + return getHeader(msg)->fcf; + } + + inline async command void IEEE154Packet2.setFCF(message_t* msg, uint16_t fcf) + { + getHeader(msg)->fcf = fcf; + } + + inline async command bool IEEE154Packet2.isDataFrame(message_t* msg) + { + return (getHeader(msg)->fcf & IEEE154_DATA_FRAME_MASK) == IEEE154_DATA_FRAME_VALUE; + } + + inline async command void IEEE154Packet2.createDataFrame(message_t* msg) + { + getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE; + } + + inline async command bool IEEE154Packet2.isAckFrame(message_t* msg) + { + return (getHeader(msg)->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; + } + + inline async command void IEEE154Packet2.createAckFrame(message_t* msg) + { + ieee154_header_t* header = getHeader(msg); + + header->length = IEEE154_ACK_FRAME_LENGTH; + header->fcf = IEEE154_ACK_FRAME_VALUE; + } + + inline async command void IEEE154Packet2.createAckReply(message_t* data, message_t* ack) + { + ieee154_header_t* header = getHeader(ack); + + header->length = IEEE154_ACK_FRAME_LENGTH; + header->fcf = IEEE154_ACK_FRAME_VALUE; + header->dsn = getHeader(data)->dsn; + } + + inline async command bool IEEE154Packet2.verifyAckReply(message_t* data, message_t* ack) + { + ieee154_header_t* header = getHeader(ack); + + return header->dsn == getHeader(data)->dsn + && (header->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; + } + + inline async command bool IEEE154Packet2.getAckRequired(message_t* msg) + { + return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ); + } + + inline async command void IEEE154Packet2.setAckRequired(message_t* msg, bool ack) + { + if( ack ) + getHeader(msg)->fcf |= (1 << IEEE154_FCF_ACK_REQ); + else + getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_ACK_REQ); + } + + inline async command bool IEEE154Packet2.getFramePending(message_t* msg) + { + return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING); + } + + inline async command void IEEE154Packet2.setFramePending(message_t* msg, bool pending) + { + if( pending ) + getHeader(msg)->fcf |= (1 << IEEE154_FCF_FRAME_PENDING); + else + getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_FRAME_PENDING); + } + + inline async command uint8_t IEEE154Packet2.getDSN(message_t* msg) + { + return getHeader(msg)->dsn; + } + + inline async command void IEEE154Packet2.setDSN(message_t* msg, uint8_t dsn) + { + getHeader(msg)->dsn = dsn; + } + + inline async command uint16_t IEEE154Packet2.getDestPan(message_t* msg) + { + return getHeader(msg)->destpan; + } + + inline async command void IEEE154Packet2.setDestPan(message_t* msg, uint16_t pan) + { + getHeader(msg)->destpan = pan; + } + + inline async command uint16_t IEEE154Packet2.getDestAddr(message_t* msg) + { + return getHeader(msg)->dest; + } + + inline async command void IEEE154Packet2.setDestAddr(message_t* msg, uint16_t addr) + { + getHeader(msg)->dest = addr; + } + + inline async command uint16_t IEEE154Packet2.getSrcAddr(message_t* msg) + { + return getHeader(msg)->src; + } + + inline async command void IEEE154Packet2.setSrcAddr(message_t* msg, uint16_t addr) + { + getHeader(msg)->src = addr; + } + +#ifndef TFRAMES_ENABLED + + inline async command uint8_t IEEE154Packet2.get6LowPan(message_t* msg) + { + return getHeader(msg)->network; + } + + inline async command void IEEE154Packet2.set6LowPan(message_t* msg, uint8_t network) + { + getHeader(msg)->network = network; + } + +#endif + + inline async command am_id_t IEEE154Packet2.getType(message_t* msg) + { + return getHeader(msg)->type; + } + + inline async command void IEEE154Packet2.setType(message_t* msg, am_id_t type) + { + getHeader(msg)->type = type; + } + + async command bool IEEE154Packet2.requiresAckWait(message_t* msg) + { + return call IEEE154Packet2.getAckRequired(msg) + && call IEEE154Packet2.isDataFrame(msg) + && call IEEE154Packet2.getDestAddr(msg) != 0xFFFF; + } + + async command bool IEEE154Packet2.requiresAckReply(message_t* msg) + { + return call IEEE154Packet2.getAckRequired(msg) + && call IEEE154Packet2.isDataFrame(msg) + && call IEEE154Packet2.getDestAddr(msg) == call ActiveMessageAddress.amAddress(); + } + + inline async event void ActiveMessageAddress.changed() + { + } + +/*----------------- AMPacket -----------------*/ + + inline command am_addr_t AMPacket.address() + { + return call ActiveMessageAddress.amAddress(); + } + + inline command am_group_t AMPacket.localGroup() + { + // TODO: check if this is correct + return call ActiveMessageAddress.amGroup(); + } + + inline command am_addr_t AMPacket.destination(message_t* msg) + { + return call IEEE154Packet2.getDestAddr(msg); + } + + inline command am_addr_t AMPacket.source(message_t* msg) + { + return call IEEE154Packet2.getSrcAddr(msg); + } + + inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr) + { + call IEEE154Packet2.setDestAddr(msg, addr); + } + + inline command void AMPacket.setSource(message_t* msg, am_addr_t addr) + { + call IEEE154Packet2.setSrcAddr(msg, addr); + } + + 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_id_t AMPacket.type(message_t* msg) + { + return call IEEE154Packet2.getType(msg); + } + + inline command void AMPacket.setType(message_t* msg, am_id_t type) + { + call IEEE154Packet2.setType(msg, type); + } + + inline command am_group_t AMPacket.group(message_t* msg) + { + return call IEEE154Packet2.getDestPan(msg); + } + + inline command void AMPacket.setGroup(message_t* msg, am_group_t grp) + { + call IEEE154Packet2.setDestPan(msg, grp); + } +} diff --git a/tos/chips/rf2xx/util/IEEE154PacketC.nc b/tos/chips/rf2xx/util/IEEE154PacketC.nc deleted file mode 100755 index 2ea8ffeb..00000000 --- a/tos/chips/rf2xx/util/IEEE154PacketC.nc +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 - */ - -configuration IEEE154PacketC -{ - provides - { - interface IEEE154Packet; - interface AMPacket; - } -} - -implementation -{ - components IEEE154PacketP, ActiveMessageAddressC; - IEEE154PacketP.ActiveMessageAddress -> ActiveMessageAddressC; - - IEEE154Packet = IEEE154PacketP; - AMPacket = IEEE154PacketP; -} diff --git a/tos/chips/rf2xx/util/IEEE154PacketP.nc b/tos/chips/rf2xx/util/IEEE154PacketP.nc deleted file mode 100644 index cb898244..00000000 --- a/tos/chips/rf2xx/util/IEEE154PacketP.nc +++ /dev/null @@ -1,294 +0,0 @@ -/* - * 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 - -module IEEE154PacketP -{ - provides - { - interface IEEE154Packet; - interface AMPacket; - } - - uses interface ActiveMessageAddress; -} - -implementation -{ -/*----------------- IEEE154Packet -----------------*/ - - enum - { - IEEE154_DATA_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE) - | (1 << IEEE154_FCF_INTRAPAN) - | (IEEE154_ADDR_MASK << IEEE154_FCF_DEST_ADDR_MODE) - | (IEEE154_ADDR_MASK << IEEE154_FCF_SRC_ADDR_MODE), - - IEEE154_DATA_FRAME_VALUE = (IEEE154_TYPE_DATA << IEEE154_FCF_FRAME_TYPE) - | (1 << IEEE154_FCF_INTRAPAN) - | (IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE) - | (IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE), - - IEEE154_ACK_FRAME_LENGTH = 5, // includes the FCF, DSN and FCS - IEEE154_ACK_FRAME_MASK = (IEEE154_TYPE_MASK << IEEE154_FCF_FRAME_TYPE), - IEEE154_ACK_FRAME_VALUE = (IEEE154_TYPE_ACK << IEEE154_FCF_FRAME_TYPE), - }; - - inline ieee154_header_t* getHeader(message_t* msg) - { - return (ieee154_header_t*)(msg->data - sizeof(ieee154_header_t)); - } - - inline async command ieee154_header_t* IEEE154Packet.getHeader(message_t* msg) - { - return getHeader(msg); - } - - inline async command uint8_t IEEE154Packet.getLength(message_t* msg) - { - return getHeader(msg)->length; - } - - inline async command void IEEE154Packet.setLength(message_t* msg, uint8_t length) - { - getHeader(msg)->length = length; - } - - inline async command uint16_t IEEE154Packet.getFCF(message_t* msg) - { - return getHeader(msg)->fcf; - } - - inline async command void IEEE154Packet.setFCF(message_t* msg, uint16_t fcf) - { - getHeader(msg)->fcf = fcf; - } - - inline async command bool IEEE154Packet.isDataFrame(message_t* msg) - { - return (getHeader(msg)->fcf & IEEE154_DATA_FRAME_MASK) == IEEE154_DATA_FRAME_VALUE; - } - - inline async command void IEEE154Packet.createDataFrame(message_t* msg) - { - getHeader(msg)->fcf = IEEE154_DATA_FRAME_VALUE; - } - - inline async command bool IEEE154Packet.isAckFrame(message_t* msg) - { - return (getHeader(msg)->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; - } - - inline async command void IEEE154Packet.createAckFrame(message_t* msg) - { - ieee154_header_t* header = getHeader(msg); - - header->length = IEEE154_ACK_FRAME_LENGTH; - header->fcf = IEEE154_ACK_FRAME_VALUE; - } - - inline async command void IEEE154Packet.createAckReply(message_t* data, message_t* ack) - { - ieee154_header_t* header = getHeader(ack); - - header->length = IEEE154_ACK_FRAME_LENGTH; - header->fcf = IEEE154_ACK_FRAME_VALUE; - header->dsn = getHeader(data)->dsn; - } - - inline async command bool IEEE154Packet.verifyAckReply(message_t* data, message_t* ack) - { - ieee154_header_t* header = getHeader(ack); - - return header->dsn == getHeader(data)->dsn - && (header->fcf & IEEE154_ACK_FRAME_MASK) == IEEE154_ACK_FRAME_VALUE; - } - - inline async command bool IEEE154Packet.getAckRequired(message_t* msg) - { - return getHeader(msg)->fcf & (1 << IEEE154_FCF_ACK_REQ); - } - - inline async command void IEEE154Packet.setAckRequired(message_t* msg, bool ack) - { - if( ack ) - getHeader(msg)->fcf |= (1 << IEEE154_FCF_ACK_REQ); - else - getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_ACK_REQ); - } - - inline async command bool IEEE154Packet.getFramePending(message_t* msg) - { - return getHeader(msg)->fcf & (1 << IEEE154_FCF_FRAME_PENDING); - } - - inline async command void IEEE154Packet.setFramePending(message_t* msg, bool pending) - { - if( pending ) - getHeader(msg)->fcf |= (1 << IEEE154_FCF_FRAME_PENDING); - else - getHeader(msg)->fcf &= ~(uint16_t)(1 << IEEE154_FCF_FRAME_PENDING); - } - - inline async command uint8_t IEEE154Packet.getDSN(message_t* msg) - { - return getHeader(msg)->dsn; - } - - inline async command void IEEE154Packet.setDSN(message_t* msg, uint8_t dsn) - { - getHeader(msg)->dsn = dsn; - } - - inline async command uint16_t IEEE154Packet.getDestPan(message_t* msg) - { - return getHeader(msg)->destpan; - } - - inline async command void IEEE154Packet.setDestPan(message_t* msg, uint16_t pan) - { - getHeader(msg)->destpan = pan; - } - - inline async command uint16_t IEEE154Packet.getDestAddr(message_t* msg) - { - return getHeader(msg)->dest; - } - - inline async command void IEEE154Packet.setDestAddr(message_t* msg, uint16_t addr) - { - getHeader(msg)->dest = addr; - } - - inline async command uint16_t IEEE154Packet.getSrcAddr(message_t* msg) - { - return getHeader(msg)->src; - } - - inline async command void IEEE154Packet.setSrcAddr(message_t* msg, uint16_t addr) - { - getHeader(msg)->src = addr; - } - -#ifndef TFRAMES_ENABLED - - inline async command uint8_t IEEE154Packet.get6LowPan(message_t* msg) - { - return getHeader(msg)->network; - } - - inline async command void IEEE154Packet.set6LowPan(message_t* msg, uint8_t network) - { - getHeader(msg)->network = network; - } - -#endif - - inline async command am_id_t IEEE154Packet.getType(message_t* msg) - { - return getHeader(msg)->type; - } - - inline async command void IEEE154Packet.setType(message_t* msg, am_id_t type) - { - getHeader(msg)->type = type; - } - - async command bool IEEE154Packet.requiresAckWait(message_t* msg) - { - return call IEEE154Packet.getAckRequired(msg) - && call IEEE154Packet.isDataFrame(msg) - && call IEEE154Packet.getDestAddr(msg) != 0xFFFF; - } - - async command bool IEEE154Packet.requiresAckReply(message_t* msg) - { - return call IEEE154Packet.getAckRequired(msg) - && call IEEE154Packet.isDataFrame(msg) - && call IEEE154Packet.getDestAddr(msg) == call ActiveMessageAddress.amAddress(); - } - - inline async event void ActiveMessageAddress.changed() - { - } - -/*----------------- AMPacket -----------------*/ - - inline command am_addr_t AMPacket.address() - { - return call ActiveMessageAddress.amAddress(); - } - - inline command am_group_t AMPacket.localGroup() - { - // TODO: check if this is correct - return call ActiveMessageAddress.amGroup(); - } - - inline command am_addr_t AMPacket.destination(message_t* msg) - { - return call IEEE154Packet.getDestAddr(msg); - } - - inline command am_addr_t AMPacket.source(message_t* msg) - { - return call IEEE154Packet.getSrcAddr(msg); - } - - inline command void AMPacket.setDestination(message_t* msg, am_addr_t addr) - { - call IEEE154Packet.setDestAddr(msg, addr); - } - - inline command void AMPacket.setSource(message_t* msg, am_addr_t addr) - { - call IEEE154Packet.setSrcAddr(msg, addr); - } - - 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_id_t AMPacket.type(message_t* msg) - { - return call IEEE154Packet.getType(msg); - } - - inline command void AMPacket.setType(message_t* msg, am_id_t type) - { - call IEEE154Packet.setType(msg, type); - } - - inline command am_group_t AMPacket.group(message_t* msg) - { - return call IEEE154Packet.getDestPan(msg); - } - - inline command void AMPacket.setGroup(message_t* msg, am_group_t grp) - { - call IEEE154Packet.setDestPan(msg, grp); - } -}