* Author: Miklos Maroti
*/
-#include <RF212Packet.h>
+#include <RF212ActiveMessage.h>
#include <RadioConfig.h>
#include <Tasklet.h>
interface SlottedCollisionConfig;
interface ActiveMessageConfig;
interface DummyConfig;
+
+#ifdef LOW_POWER_LISTENING
+ interface LowPowerListeningConfig;
+#endif
}
uses
{
- interface IEEE154Packet;
- interface Packet;
+ interface IEEE154MessageLayer;
interface RadioAlarm;
+ interface RadioPacket as ActiveMessagePacket;
+ interface RadioPacket as RF212Packet;
+
+ interface PacketTimeStamp<TRadio, uint32_t>;
}
}
implementation
{
-/*----------------- RF212DriverConfig -----------------*/
- async command uint8_t RF212DriverConfig.getLength(message_t* msg)
- {
- return call IEEE154Packet.getLength(msg);
- }
+/*----------------- RF212DriverConfig -----------------*/
- async command void RF212DriverConfig.setLength(message_t* msg, uint8_t len)
+ async command uint8_t RF212DriverConfig.headerLength(message_t* msg)
{
- call IEEE154Packet.setLength(msg, len);
+ return offsetof(message_t, data) - sizeof(rf212packet_header_t);
}
- async command uint8_t* RF212DriverConfig.getPayload(message_t* msg)
+ async command uint8_t RF212DriverConfig.maxPayloadLength()
{
- return ((uint8_t*)(call IEEE154Packet.getHeader(msg))) + 1;
+ return sizeof(rf212packet_header_t) + TOSH_DATA_LENGTH;
}
- inline rf212packet_metadata_t* getMeta(message_t* msg)
+ async command uint8_t RF212DriverConfig.metadataLength(message_t* msg)
{
- return (rf212packet_metadata_t*)(msg->metadata);
+ return 0;
}
- async command uint8_t RF212DriverConfig.getHeaderLength()
+ async command uint8_t RF212DriverConfig.headerPreloadLength()
{
// we need the fcf, dsn, destpan and dest
return 7;
}
- async command uint8_t RF212DriverConfig.getMaxLength()
- {
- // note, that the ieee154_footer_t is not stored, but we should include it here
- return sizeof(rf212packet_header_t) - 1 + TOSH_DATA_LENGTH + sizeof(ieee154_footer_t);
- }
-
- async command uint8_t RF212DriverConfig.getDefaultChannel()
- {
- return RF212_DEF_CHANNEL;
- }
-
async command bool RF212DriverConfig.requiresRssiCca(message_t* msg)
{
- return call IEEE154Packet.isDataFrame(msg);
+ return call IEEE154MessageLayer.isDataFrame(msg);
}
/*----------------- SoftwareAckConfig -----------------*/
async command bool SoftwareAckConfig.requiresAckWait(message_t* msg)
{
- return call IEEE154Packet.requiresAckWait(msg);
+ return call IEEE154MessageLayer.requiresAckWait(msg);
}
async command bool SoftwareAckConfig.isAckPacket(message_t* msg)
{
- return call IEEE154Packet.isAckFrame(msg);
+ return call IEEE154MessageLayer.isAckFrame(msg);
}
async command bool SoftwareAckConfig.verifyAckPacket(message_t* data, message_t* ack)
{
- return call IEEE154Packet.verifyAckReply(data, ack);
+ return call IEEE154MessageLayer.verifyAckReply(data, ack);
}
- async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
+ async command void SoftwareAckConfig.setAckRequired(message_t* msg, bool ack)
{
- return call IEEE154Packet.requiresAckReply(msg);
+ call IEEE154MessageLayer.setAckRequired(msg, ack);
}
- async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
+ async command bool SoftwareAckConfig.requiresAckReply(message_t* msg)
{
- call IEEE154Packet.createAckReply(data, ack);
+ return call IEEE154MessageLayer.requiresAckReply(msg);
}
- async command void SoftwareAckConfig.setAckReceived(message_t* msg, bool acked)
+ async command void SoftwareAckConfig.createAckPacket(message_t* data, message_t* ack)
{
- if( acked )
- getMeta(msg)->flags |= RF212PACKET_WAS_ACKED;
- else
- getMeta(msg)->flags &= ~RF212PACKET_WAS_ACKED;
+ call IEEE154MessageLayer.createAckReply(data, ack);
}
async command uint16_t SoftwareAckConfig.getAckTimeout()
async command uint8_t UniqueConfig.getSequenceNumber(message_t* msg)
{
- return call IEEE154Packet.getDSN(msg);
+ return call IEEE154MessageLayer.getDSN(msg);
}
async command void UniqueConfig.setSequenceNumber(message_t* msg, uint8_t dsn)
{
- call IEEE154Packet.setDSN(msg, dsn);
+ call IEEE154MessageLayer.setDSN(msg, dsn);
}
async command am_addr_t UniqueConfig.getSender(message_t* msg)
{
- return call IEEE154Packet.getSrcAddr(msg);
+ return call IEEE154MessageLayer.getSrcAddr(msg);
}
tasklet_async command void UniqueConfig.reportChannelError()
/*----------------- ActiveMessageConfig -----------------*/
- command error_t ActiveMessageConfig.checkPacket(message_t* msg)
+ 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)
{
- // the user forgot to call clear, we should return EINVAL
- if( ! call IEEE154Packet.isDataFrame(msg) )
- call Packet.clear(msg);
+ 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);
+ }
- return SUCCESS;
+ 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 IEEE154Packet.isDataFrame(msg);
+ return call IEEE154MessageLayer.isDataFrame(msg);
}
/*----------------- TrafficMonitorConfig -----------------*/
* 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 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 IEEE154Packet.getSrcAddr(msg);
+ return call IEEE154MessageLayer.getSrcAddr(msg);
}
tasklet_async command void TrafficMonitorConfig.timerTick()
time = call RadioAlarm.getNow();
// estimated response time (download the message, etc) is 5-8 bytes
- if( call IEEE154Packet.requiresAckReply(msg) )
+ 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() { }
+ tasklet_async event void RadioAlarm.fired()
+ {
+ }
/*----------------- SlottedCollisionConfig -----------------*/
async command uint16_t SlottedCollisionConfig.getTransmitTime(message_t* msg)
{
// TODO: check if the timestamp is correct
- return getMeta(msg)->timestamp;
+ 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 getMeta(msg)->timestamp - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
+ return (call PacketTimeStamp.timestamp(msg)) - (uint16_t)(7 * 32 * RADIO_ALARM_MICROSEC);
}
async command uint16_t SlottedCollisionConfig.getCollisionWindowLength(message_t* msg)
async command void DummyConfig.nothing()
{
}
+
+/*----------------- LowPowerListening -----------------*/
+
+#ifdef LOW_POWER_LISTENING
+
+ async command bool LowPowerListeningConfig.getAckRequired(message_t* msg)
+ {
+ return call IEEE154MessageLayer.getAckRequired(msg);
+ }
+
+#endif
+
}