]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- commit reorg of 2420 stack to support Ieee154 messaging component
authorsdhsdh <sdhsdh>
Sat, 29 Aug 2009 00:06:42 +0000 (00:06 +0000)
committersdhsdh <sdhsdh>
Sat, 29 Aug 2009 00:06:42 +0000 (00:06 +0000)
16 files changed:
tos/chips/cc2420/CC2420.h
tos/chips/cc2420/CC2420ActiveMessageC.nc
tos/chips/cc2420/CC2420ActiveMessageP.nc
tos/chips/cc2420/csma/CC2420CsmaP.nc
tos/chips/cc2420/interfaces/CC2420Packet.nc
tos/chips/cc2420/link/PacketLinkC.nc
tos/chips/cc2420/link/PacketLinkDummyC.nc
tos/chips/cc2420/link/PacketLinkP.nc
tos/chips/cc2420/lowpan/CC2420TinyosNetworkC.nc
tos/chips/cc2420/lowpan/CC2420TinyosNetworkP.nc
tos/chips/cc2420/lpl/DefaultLplC.nc
tos/chips/cc2420/lpl/DefaultLplP.nc
tos/chips/cc2420/packet/CC2420PacketC.nc
tos/chips/cc2420/packet/CC2420PacketP.nc
tos/chips/cc2420/receive/CC2420ReceiveP.nc
tos/chips/cc2420/transmit/CC2420TransmitP.nc

index bdaefd6b4c5b6cf92a15ad04c0d8ad54af929556..d554f2d92a21aeabdfaa1029ee3a544ab44836d3 100644 (file)
 
 typedef uint8_t cc2420_status_t;
 
-#ifndef TFRAMES_ENABLED
+#if !defined(TFRAMES_ENABLED) && !defined(IEEE154FRAMES_ENABLED)
 #define CC2420_IFRAME_TYPE
 #endif
 
+#if defined(TFRAMES_ENABLED) && defined(IEEE154FRAMES_ENABLED)
+#error "Both TFRAMES and IEEE154FRAMES enabled!"
+#endif
+
 /**
  * CC2420 header definition.
  * 
@@ -99,20 +103,21 @@ typedef nx_struct cc2420_header_t {
   nxle_uint16_t destpan;
   nxle_uint16_t dest;
   nxle_uint16_t src;
-
-#ifdef CC2420_HW_SECURITY
-  security_header_t secHdr;
-#endif
+  /** CC2420 802.15.4 header ends here */
   
-  /** I-Frame 6LowPAN interoperability byte */
 #ifdef CC2420_IFRAME_TYPE
+  /** I-Frame 6LowPAN interoperability byte */
   nxle_uint8_t network;
 #endif
 
-#ifndef TINYOS_IP
+#if defined(TFRAMES_ENABLED) || defined(CC2420_IFRAME_TYPE)
   nxle_uint8_t type;
 #endif
 
+#ifdef CC2420_HW_SECURITY
+  security_header_t secHdr;
+#endif
+
 } cc2420_header_t;
 
 /**
@@ -143,7 +148,6 @@ typedef nx_struct cc2420_metadata_t {
   nx_uint16_t maxRetries;
   nx_uint16_t retryDelay;
 #endif
-
 } cc2420_metadata_t;
 
 
@@ -180,7 +184,6 @@ typedef nx_struct cc2420_packet_t {
 #define TINYOS_6LOWPAN_NETWORK_ID 0x3f
 #endif
 
-
 enum {
   // size of the header not including the length byte
   MAC_HEADER_SIZE = sizeof( cc2420_header_t ) - 1,
@@ -189,9 +192,20 @@ enum {
   // MDU
   MAC_PACKET_SIZE = MAC_HEADER_SIZE + TOSH_DATA_LENGTH + MAC_FOOTER_SIZE,
 
-  CC2420_SIZE = MAC_HEADER_SIZE + MAC_FOOTER_SIZE,
+  AM_OVERHEAD = 0
+#if defined(TFRAMES_ENABLED) || defined(CC2420_IFRAME_TYPE)
+  + 1 // add one for the AM byte
+#if defined(CC2420_IFRAME_TYPE)
+  + 1 // and one for the network byte
+#endif
+#endif    
+  ,
+
+  CC2420_SIZE = MAC_HEADER_SIZE + MAC_FOOTER_SIZE - AM_OVERHEAD,
 };
 
+#define CC2420_PAYLOAD(mbuf)  (((uint8_t *)(mbuf)->data) - AM_OVERHEAD)
+
 enum cc2420_enums {
   CC2420_TIME_ACK_TURNAROUND = 7, // jiffies
   CC2420_TIME_VREN = 20,          // jiffies
index 509bc6fb869de26da15ef36a8911251248e827e5..e80e033d10396b73b876b9fb3ab8524aab61d46b 100644 (file)
 
 #include "CC2420.h"
 #include "AM.h"
+#include "Ieee154.h"
+
+#ifdef IEEE154FRAMES_ENABLED
+#error "CC2420 AM layer cannot work when IEEE 802.15.4 frames only are used"
+#endif
 
 configuration CC2420ActiveMessageC {
   provides {
@@ -55,29 +60,18 @@ configuration CC2420ActiveMessageC {
   }
 }
 implementation {
+  enum {
+    CC2420_AM_SEND_ID     = unique(IEEE154_SEND_CLIENT),
+  };
 
+  components CC2420RadioC as Radio;
   components CC2420ActiveMessageP as AM;
-  components CC2420CsmaC as CsmaC;
   components ActiveMessageAddressC;
-  components UniqueSendC;
-  components UniqueReceiveC;
-  components CC2420TinyosNetworkC;
-  components CC2420PacketC;
+  components CC2420CsmaC as CsmaC;
   components CC2420ControlC;
+  components CC2420PacketC;
   
-#if defined(LOW_POWER_LISTENING) || defined(ACK_LOW_POWER_LISTENING)
-  components DefaultLplC as LplC;
-#else
-  components DummyLplC as LplC;
-#endif
-
-#if defined(PACKET_LINK)
-  components PacketLinkC as LinkC;
-#else
-  components PacketLinkDummyC as LinkC;
-#endif
-
-  
+  SplitControl = Radio;
   RadioBackoff = AM;
   Packet = AM;
   AMSend = AM;
@@ -85,28 +79,16 @@ implementation {
   Receive = AM.Receive;
   Snoop = AM.Snoop;
   AMPacket = AM;
-  PacketLink = LinkC;
-  LowPowerListening = LplC;
-  CC2420Packet = CC2420PacketC;
-  PacketAcknowledgements = CC2420PacketC;
-  LinkPacketMetadata = CC2420PacketC;
+  PacketLink = Radio;
+  LowPowerListening = Radio;
+  CC2420Packet = Radio;
+  PacketAcknowledgements = Radio;
+  LinkPacketMetadata = Radio;
   
-  // SplitControl Layers
-  SplitControl = LplC;
-  LplC.SubControl -> CsmaC;
-  
-  // Send Layers
-  AM.SubSend -> UniqueSendC;
-  UniqueSendC.SubSend -> LinkC;
-  LinkC.SubSend -> LplC.Send;
-  LplC.SubSend -> CC2420TinyosNetworkC.Send;
-  CC2420TinyosNetworkC.SubSend -> CsmaC;
-  
-  // Receive Layers
-  AM.SubReceive -> LplC;
-  LplC.SubReceive -> UniqueReceiveC.Receive;
-  UniqueReceiveC.SubReceive -> CC2420TinyosNetworkC.Receive;
-  CC2420TinyosNetworkC.SubReceive -> CsmaC;
+  // Radio resource for the AM layer
+  AM.RadioResource -> Radio.Resource[CC2420_AM_SEND_ID];
+  AM.SubSend -> Radio.ActiveSend;
+  AM.SubReceive -> Radio.ActiveReceive;
 
   AM.ActiveMessageAddress -> ActiveMessageAddressC;
   AM.CC2420Packet -> CC2420PacketC;
@@ -114,4 +96,7 @@ implementation {
   AM.CC2420Config -> CC2420ControlC;
   
   AM.SubBackoff -> CsmaC;
+
+  components LedsC;
+  AM.Leds -> LedsC;
 }
index 0db2423c7b83167d7bf41b4797e85c117b52cb8f..a729cdac507288eb4f98b3570411c971f0c66b3b 100644 (file)
@@ -53,9 +53,26 @@ module CC2420ActiveMessageP @safe() {
     interface CC2420Config;
     interface ActiveMessageAddress;
     interface RadioBackoff as SubBackoff;
+
+    interface Resource as RadioResource;
+    interface Leds;
   }
 }
 implementation {
+  uint16_t pending_length;
+  message_t *pending_message = NULL;
+  /***************** Resource event  ****************/
+  event void RadioResource.granted() {
+    uint8_t rc;
+    cc2420_header_t* header = call CC2420PacketBody.getHeader( pending_message );
+
+    signal SendNotifier.aboutToSend[header->type](header->dest, pending_message);
+    rc = call SubSend.send( pending_message, pending_length );
+    if (rc != SUCCESS) {
+      call RadioResource.release();
+      signal AMSend.sendDone[header->type]( pending_message, rc );
+    }
+  }
 
   /***************** AMSend Commands ****************/
   command error_t AMSend.send[am_id_t id](am_addr_t addr,
@@ -72,9 +89,21 @@ implementation {
     header->destpan = call CC2420Config.getPanAddr();
     header->src = call AMPacket.address();
     
-    signal SendNotifier.aboutToSend[id](addr, msg);
-    
-    return call SubSend.send( msg, len );
+    if (call RadioResource.immediateRequest() == SUCCESS) {
+      error_t rc;
+      signal SendNotifier.aboutToSend[id](addr, msg);
+      
+      rc = call SubSend.send( msg, len );
+      if (rc != SUCCESS) {
+        call RadioResource.release();
+      }
+
+      return rc;
+    } else {
+      pending_length  = len;
+      pending_message = msg;
+      return call RadioResource.request();
+    }
   }
 
   command error_t AMSend.cancel[am_id_t id](message_t* msg) {
@@ -150,15 +179,15 @@ implementation {
   }
   
   command uint8_t Packet.payloadLength(message_t* msg) {
-    return (call CC2420PacketBody.getHeader(msg))->length - CC2420_SIZE;
+    return (call CC2420PacketBody.getHeader(msg))->length - CC2420_SIZE - AM_OVERHEAD;
   }
   
   command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
-    (call CC2420PacketBody.getHeader(msg))->length  = len + CC2420_SIZE;
+    (call CC2420PacketBody.getHeader(msg))->length  = len + CC2420_SIZE + AM_OVERHEAD;
   }
   
   command uint8_t Packet.maxPayloadLength() {
-    return TOSH_DATA_LENGTH;
+    return call SubSend.maxPayloadLength();
   }
   
   command void* Packet.getPayload(message_t* msg, uint8_t len) {
@@ -168,6 +197,7 @@ implementation {
   
   /***************** SubSend Events ****************/
   event void SubSend.sendDone(message_t* msg, error_t result) {
+    call RadioResource.release();
     signal AMSend.sendDone[call AMPacket.type(msg)](msg, result);
   }
 
@@ -175,10 +205,6 @@ implementation {
   /***************** SubReceive Events ****************/
   event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) {
     
-    if(!(call CC2420PacketBody.getMetadata(msg))->crc) {
-      return msg;
-    }
-    
     if (call AMPacket.isForMe(msg)) {
       return signal Receive.receive[call AMPacket.type(msg)](msg, payload, len);
     }
@@ -235,8 +261,6 @@ implementation {
   async command void RadioBackoff.setCca[am_id_t amId](bool useCca) {
     call SubBackoff.setCca(useCca);
   }
-
-
   
   /***************** Defaults ****************/
   default event message_t* Receive.receive[am_id_t id](message_t* msg, void* payload, uint8_t len) {
@@ -248,6 +272,7 @@ implementation {
   }
 
   default event void AMSend.sendDone[uint8_t id](message_t* msg, error_t err) {
+    call RadioResource.release();
   }
 
   default event void SendNotifier.aboutToSend[am_id_t amId](am_addr_t addr, message_t *msg) {
index 7c0ef75deda6505e04ea073b4edda864e4807adc..82f4412ed12b6cf044a659ffa5cf12a5898e5b40 100644 (file)
@@ -160,7 +160,7 @@ implementation {
 
   command void* Send.getPayload(message_t* m, uint8_t len) {
     if (len <= call Send.maxPayloadLength()) {
-      return (void* COUNT_NOK(len))m->data;
+      return (void* COUNT_NOK(len ))(CC2420_PAYLOAD(m));
     }
     else {
       return NULL;
@@ -168,7 +168,7 @@ implementation {
   }
 
   command uint8_t Send.maxPayloadLength() {
-    return TOSH_DATA_LENGTH;
+    return TOSH_DATA_LENGTH + AM_OVERHEAD;
   }
 
   /**************** RadioBackoff Commands ****************/
index b18df717a1080f3f14667ca71fc62dbd807d3612..1c403fe908b3955b229a6fac28c1123da1c4ee25 100644 (file)
@@ -70,5 +70,10 @@ interface CC2420Packet {
    * ack was received.
    */
   async command uint8_t getLqi( message_t* p_msg );
+
+
+  async command uint8_t getNetwork( message_t* p_msg );
+
+  async command void setNetwork( message_t* p_msg, uint8_t networkId );
   
 }
index 9e2c273aa0e0621650f2eea77c2bff7bffff7781..829d32bc37daf7d4f9806d676a1011ccb4b5a78c 100644 (file)
@@ -51,7 +51,6 @@ configuration PacketLinkC {
 implementation {
 
   components PacketLinkP,
-      ActiveMessageC,
       CC2420PacketC,
       RandomC,
       new StateC() as SendStateC,
@@ -63,8 +62,7 @@ implementation {
   
   PacketLinkP.SendState -> SendStateC;
   PacketLinkP.DelayTimer -> DelayTimerC;
-  PacketLinkP.PacketAcknowledgements -> ActiveMessageC;
-  PacketLinkP.AMPacket -> ActiveMessageC;
+  PacketLinkP.PacketAcknowledgements -> CC2420PacketC;
   PacketLinkP.CC2420PacketBody -> CC2420PacketC;
 
 }
index 2ea159cef3c9492ce2d565b40fea2af258a8dd02..de1ef6d8c81655393ac9b9ce4e37161a4f626f32 100644 (file)
@@ -48,12 +48,12 @@ configuration PacketLinkDummyC {
 
 implementation {
   components PacketLinkDummyP,
-      ActiveMessageC;
+      CC2420RadioC;
   
   PacketLink = PacketLinkDummyP;
   Send = SubSend;
   
-  PacketLinkDummyP.PacketAcknowledgements -> ActiveMessageC;
+  PacketLinkDummyP.PacketAcknowledgements -> CC2420RadioC;
   
 }
 
index fef6c2bf21319875071874da366c9e5914e25645..0622fcda04cd418f69e83fe633c7202f9b26efff 100644 (file)
@@ -48,7 +48,6 @@ module PacketLinkP {
     interface State as SendState;
     interface PacketAcknowledgements;
     interface Timer<TMilli> as DelayTimer;
-    interface AMPacket;
     interface CC2420PacketBody;
   }
 }
@@ -221,6 +220,7 @@ implementation {
   void signalDone(error_t error) {
     call DelayTimer.stop();
     call SendState.toIdle();
+    (call CC2420PacketBody.getMetadata(currentSendMsg))->maxRetries = totalRetries;
     signal Send.sendDone(currentSendMsg, error);
   }
 }
index 3581b120f0d91b0d4d8b1fc87ad2c13c2a2a3b64..67e71d1ab089cf906a7b22c8ecc02a80187114e8 100644 (file)
  */
  
 #include "CC2420.h"
+#include "Ieee154.h"
 
 configuration CC2420TinyosNetworkC {
   provides {
+    interface Resource[uint8_t clientId];
     interface Send;
     interface Receive;
+
+    interface Send as ActiveSend;
+    interface Receive as ActiveReceive;
   }
   
   uses {
@@ -72,21 +77,27 @@ configuration CC2420TinyosNetworkC {
 
 implementation {
 
-#ifdef CC2420_IFRAME_TYPE
+  enum {
+    TINYOS_N_NETWORKS = uniqueCount(IEEE154_SEND_CLIENT),
+  };
+
+  components MainC;
   components CC2420TinyosNetworkP;
   components CC2420PacketC;
-  
-  CC2420TinyosNetworkP.Send = Send;
-  CC2420TinyosNetworkP.Receive = Receive;
+  components new FcfsResourceQueueC(TINYOS_N_NETWORKS);
+
+  CC2420TinyosNetworkP.BareSend = Send;
+  CC2420TinyosNetworkP.BareReceive = Receive;
   CC2420TinyosNetworkP.SubSend = SubSend;
   CC2420TinyosNetworkP.SubReceive = SubReceive;
-  
-  CC2420TinyosNetworkP.CC2420PacketBody -> CC2420PacketC;
+  CC2420TinyosNetworkP.Resource = Resource;
+  CC2420TinyosNetworkP.ActiveSend = ActiveSend;
+  CC2420TinyosNetworkP.ActiveReceive = ActiveReceive;
 
-#else
-  Send = SubSend;
-  Receive = SubReceive;
-#endif
+  CC2420TinyosNetworkP.CC2420Packet -> CC2420PacketC;
+  CC2420TinyosNetworkP.CC2420PacketBody -> CC2420PacketC;
+  CC2420TinyosNetworkP.Queue -> FcfsResourceQueueC;
 
+  MainC.SoftwareInit -> FcfsResourceQueueC;
 }
 
index e490f37cece3c55e6f3eccbc3ed3a93086037d7e..8a2223953d4be0e1acb83df1b6f9f0bee40f1768 100644 (file)
  *
  * @author David Moss
  */
+
 #include "CC2420.h"
+#include "Ieee154.h"
 
 module CC2420TinyosNetworkP @safe() {
   provides {
-    interface Send;
-    interface Receive;
-    
-    interface Receive as NonTinyosReceive[uint8_t networkId];
+    interface Resource[uint8_t client];
+
+    interface Send as BareSend;
+    interface Receive as BareReceive;
+
+    interface Send as ActiveSend;
+    interface Receive as ActiveReceive;
   }
   
   uses {
     interface Send as SubSend;
     interface Receive as SubReceive;
+    interface CC2420Packet;
     interface CC2420PacketBody;
+    interface ResourceQueue as Queue;
   }
 }
 
 implementation {
 
+  enum {
+    OWNER_NONE = 0xff,
+    TINYOS_N_NETWORKS = uniqueCount(IEEE154_SEND_CLIENT),
+  } state;
+
+  norace uint8_t resource_owner = OWNER_NONE, next_owner;
+
+  command error_t ActiveSend.send(message_t* msg, uint8_t len) {
+    call CC2420Packet.setNetwork(msg, TINYOS_6LOWPAN_NETWORK_ID);
+    return call BareSend.send(msg, len + AM_OVERHEAD);
+  }
+
+  command error_t ActiveSend.cancel(message_t* msg) {
+    return call BareSend.cancel(msg);
+  }
+
+  command uint8_t ActiveSend.maxPayloadLength() {
+    return call BareSend.maxPayloadLength() - AM_OVERHEAD;
+  }
+
+  command void* ActiveSend.getPayload(message_t* msg, uint8_t len) {
+    if (len <= call ActiveSend.maxPayloadLength()) {
+      return msg->data;
+    } else {
+      return NULL;
+    }
+  }
+
   /***************** Send Commands ****************/
-  command error_t Send.send(message_t* msg, uint8_t len) {
-    (call CC2420PacketBody.getHeader(msg))->network = TINYOS_6LOWPAN_NETWORK_ID;
+  command error_t BareSend.send(message_t* msg, uint8_t len) {
     return call SubSend.send(msg, len);
   }
 
-  command error_t Send.cancel(message_t* msg) {
+  command error_t BareSend.cancel(message_t* msg) {
     return call SubSend.cancel(msg);
   }
 
-  command uint8_t Send.maxPayloadLength() {
+  command uint8_t BareSend.maxPayloadLength() {
     return call SubSend.maxPayloadLength();
   }
 
-  command void* Send.getPayload(message_t* msg, uint8_t len) {
+  command void* BareSend.getPayload(message_t* msg, uint8_t len) {
     return call SubSend.getPayload(msg, len);
   }
   
   /***************** SubSend Events *****************/
   event void SubSend.sendDone(message_t* msg, error_t error) {
-    signal Send.sendDone(msg, error);
+    if (call CC2420Packet.getNetwork(msg) == TINYOS_6LOWPAN_NETWORK_ID) {
+      signal ActiveSend.sendDone(msg, error);
+    } else {
+      signal BareSend.sendDone(msg, error);
+    }
   }
   
   /***************** SubReceive Events ***************/
   event message_t *SubReceive.receive(message_t *msg, void *payload, uint8_t len) {
-    if((call CC2420PacketBody.getHeader(msg))->network == TINYOS_6LOWPAN_NETWORK_ID) {
-      return signal Receive.receive(msg, payload, len);
-      
+
+    if(!(call CC2420PacketBody.getMetadata(msg))->crc) {
+      return msg;
+    }
+
+    if (call CC2420Packet.getNetwork(msg) == TINYOS_6LOWPAN_NETWORK_ID) {
+      return signal ActiveReceive.receive(msg, msg->data, len - AM_OVERHEAD);
     } else {
-      return signal NonTinyosReceive.receive[(call CC2420PacketBody.getHeader(msg))->network](msg, payload, len);
+      return signal BareReceive.receive(msg, payload, len);
     }
   }
-  
+
+  /***************** Resource ****************/
+  // SDH : 8-7-2009 : testing if there's more then one client allows
+  // the compiler to eliminate most of the logic when there's only one
+  // client.
+  task void grantTask() {
+
+
+    if (TINYOS_N_NETWORKS > 1) {
+      if (resource_owner == OWNER_NONE && !(call Queue.isEmpty())) {
+        resource_owner = call Queue.dequeue();
+
+        if (resource_owner != OWNER_NONE) {
+          signal Resource.granted[resource_owner]();
+        }
+      }
+    } else {
+      if (next_owner != resource_owner) {
+        resource_owner = next_owner;
+        signal Resource.granted[resource_owner]();
+      }
+    }
+  }
+
+  async command error_t Resource.request[uint8_t id]() {
+
+    post grantTask();
+
+    if (TINYOS_N_NETWORKS > 1) {
+      return call Queue.enqueue(id);
+    } else {
+      if (id == resource_owner) {
+        return EALREADY;
+      } else {
+        next_owner = id;
+        return SUCCESS;
+      }
+    }
+  }
+
+  async command error_t Resource.immediateRequest[uint8_t id]() {
+    if (resource_owner == id) return EALREADY;
+
+    if (TINYOS_N_NETWORKS > 1) {
+      if (resource_owner == OWNER_NONE && call Queue.isEmpty()) {
+        resource_owner = id;
+        return SUCCESS;
+      }
+      return FAIL;
+    } else {
+      resource_owner = id;
+      return SUCCESS;
+    }
+  }
+  async command error_t Resource.release[uint8_t id]() {
+    if (TINYOS_N_NETWORKS > 1) {
+      post grantTask();
+    }
+    resource_owner = OWNER_NONE;
+    return SUCCESS;
+  }
+  async command bool Resource.isOwner[uint8_t id]() {
+    return (id == resource_owner);
+  }
+
   /***************** Defaults ****************/
-  default event message_t *NonTinyosReceive.receive[uint8_t networkId](message_t *msg, void *payload, uint8_t len) {
+  default event message_t *BareReceive.receive(message_t *msg, void *payload, uint8_t len) {
     return msg;
   }
-  
+  default event void BareSend.sendDone(message_t *msg, error_t error) {
+
+  }
+  default event message_t *ActiveReceive.receive(message_t *msg, void *payload, uint8_t len) {
+    return msg;
+  }
+  default event void ActiveSend.sendDone(message_t *msg, error_t error) {
+
+  }
+  default event void Resource.granted[uint8_t client]() {
+    call Resource.release[client]();
+  }
+
 }
index 4fc8b7e18e6c400ab493f27d172dc0e4ee53077b..2d80b9f3f23232ac12ddc305d598611ce4dea0f7 100644 (file)
@@ -58,7 +58,7 @@ implementation {
   components MainC,
       DefaultLplP,
       PowerCycleC,
-      CC2420ActiveMessageC,
+      CC2420RadioC,
       CC2420CsmaC,
       CC2420TransmitC,
       CC2420PacketC,
@@ -89,8 +89,7 @@ implementation {
   DefaultLplP.SendDoneTimer -> SendDoneTimerC;
   DefaultLplP.PowerCycle -> PowerCycleC;
   DefaultLplP.Resend -> CC2420TransmitC;
-  DefaultLplP.PacketAcknowledgements -> CC2420ActiveMessageC;
-  DefaultLplP.AMPacket -> CC2420ActiveMessageC;
+  DefaultLplP.PacketAcknowledgements -> CC2420RadioC;
   DefaultLplP.CC2420PacketBody -> CC2420PacketC;
   DefaultLplP.RadioBackoff -> CC2420CsmaC;
   DefaultLplP.Random -> RandomC;
index 3ada9db65353e9e75ee182fecf2c558124f87ac0..a1cf07cfe6bee4dbeff009d54ec4865b40479cd7 100644 (file)
@@ -56,7 +56,6 @@ module DefaultLplP {
     interface CC2420Transmit as Resend;
     interface RadioBackoff;
     interface Receive as SubReceive;
-    interface AMPacket;
     interface SplitControl as SubControl;
     interface PowerCycle;
     interface CC2420PacketBody;
@@ -484,7 +483,7 @@ implementation {
     if(call LowPowerListening.getRxSleepInterval(currentSendMsg) 
       > ONE_MESSAGE) {
     
-      if(call AMPacket.destination(currentSendMsg) == AM_BROADCAST_ADDR) {
+      if((call CC2420PacketBody.getHeader(currentSendMsg))->dest == IEEE154_BROADCAST_ADDR) {
         call PacketAcknowledgements.noAck(currentSendMsg);
       } else {
         // Send it repetitively within our transmit window
index de537664f7284389ea7898884d292b564c6a9c15..9e3415546b1c8d1efb0811ab236f04383d77f9ee 100644 (file)
@@ -60,9 +60,6 @@ implementation {
   PacketTimeStampMilli = CC2420PacketP;
   PacketTimeSyncOffset = CC2420PacketP;
 
-  components CC2420ActiveMessageC;
-  CC2420PacketP.Packet -> CC2420ActiveMessageC;
-
   components Counter32khz32C, new CounterToLocalTimeC(T32khz);
   CounterToLocalTimeC.Counter -> Counter32khz32C;
   CC2420PacketP.LocalTime32khz -> CounterToLocalTimeC;
index f0c2e3849ba639be9d653fe5b8894f7b85ce5013..ec4b50df881ea5c91e1a9ff018cf836f2793d735 100644 (file)
@@ -95,6 +95,23 @@ implementation {
     return (call CC2420PacketBody.getMetadata( p_msg ))->lqi;
   }
 
+  async command uint8_t CC2420Packet.getNetwork( message_t* p_msg ) {
+#if defined(CC2420_IFRAME_TYPE)
+    return (call CC2420PacketBody.getHeader( p_msg ))->network;
+#elif defined(IEEE154FRAMES_ENABLED)
+    return 0;
+#else
+    return TINYOS_6LOWPAN_NETWORK_ID;
+#endif
+  }
+
+  async command void CC2420Packet.setNetwork( message_t* p_msg , uint8_t networkId ) {
+#if defined(CC2420_IFRAME_TYPE)
+    (call CC2420PacketBody.getHeader( p_msg ))->network = networkId;
+#endif
+  }    
+
+
   /***************** CC2420PacketBody Commands ****************/
   async command cc2420_header_t * ONE CC2420PacketBody.getHeader( message_t* ONE msg ) {
     return TCAST(cc2420_header_t* ONE, (uint8_t *)msg + offsetof(message_t, data) - sizeof( cc2420_header_t ));
index 80fe56d03acf39a5099cd227bce89c4a99ecedc9..7ea0957012c2b31bc5f5b58a2ed61f8d5d304283 100644 (file)
@@ -120,9 +120,6 @@ implementation {
   message_t m_rx_buf;
 #ifdef CC2420_HW_SECURITY
   norace cc2420_receive_state_t m_state;
-#else
-  cc2420_receive_state_t m_state;
-#endif
   norace uint8_t packetLength = 0;
   norace uint8_t pos = 0;
   norace uint8_t secHdrPos = 0;
@@ -134,6 +131,12 @@ implementation {
   uint8_t flush_flag = 0;
   uint16_t startTime = 0;
 
+  void beginDec();
+  void dec();
+#else
+  cc2420_receive_state_t m_state;
+#endif
+
   /***************** Prototypes ****************/
   void reset_state();
   void beginReceive();
@@ -141,8 +144,6 @@ implementation {
   void waitForNextPacket();
   void flush();
   bool passesAddressCheck(message_t * ONE msg);
-  void beginDec();
-  void dec();
 
   task void receiveDone_task();
 
@@ -532,8 +533,14 @@ implementation {
 
     case S_RX_LENGTH:
       m_state = S_RX_FCF;
+#ifdef CC2420_HW_SECURITY
       packetLength = rxFrameLength+1;
-      if ( rxFrameLength + 1 > m_bytes_left || flush_flag == 1) {
+#endif
+      if ( rxFrameLength + 1 > m_bytes_left
+#ifdef CC2420_HW_SECURITY
+           || flush_flag == 1
+#endif
+           ) {
         // Length of this packet is bigger than the RXFIFO, flush it out.
         flush();
         
@@ -686,7 +693,7 @@ implementation {
       securityOn = 0;
       authentication = 0;
 #endif
-      m_p_rx_buf = signal Receive.receive( m_p_rx_buf, m_p_rx_buf->data, 
+      m_p_rx_buf = signal Receive.receive( m_p_rx_buf, CC2420_PAYLOAD(m_p_rx_buf),
                                           length - CC2420_SIZE);
     }
     atomic receivingPacket = FALSE;
@@ -719,12 +726,14 @@ implementation {
    * Flush out the Rx FIFO
    */
   void flush() {
+#ifdef CC2420_HW_SECURITY
     flush_flag = 0;
     pos =0;
     packetLength =0;
     micLength = 0;
     securityOn = 0;
     authentication = 0;
+#endif
     reset_state();
 
     call CSN.set();
index d51cd72dccc3415fcd2c052b1b7efe2bdfc48e5b..09917c96f38e5541fdaa7113df3fe5e5859669bd 100644 (file)
@@ -106,11 +106,16 @@ implementation {
     CC2420_ABORT_PERIOD = 320
   };
 
+#ifdef CC2420_HW_SECURITY
   uint16_t startTime = 0;
   norace uint8_t secCtrlMode = 0;
   norace uint8_t nonceValue[16] = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
   norace uint8_t skip;
   norace uint16_t CTR_SECCTRL0, CTR_SECCTRL1;
+  uint8_t securityChecked = 0;
+  
+  void securityCheck();
+#endif
   
   norace message_t * ONE_NOK m_msg;
   
@@ -120,8 +125,6 @@ implementation {
   
   cc2420_transmit_state_t m_state = S_STOPPED;
 
-  uint8_t securityChecked = 0;
-  
   bool m_receiving = FALSE;
   
   uint16_t m_prev_time;
@@ -147,7 +150,6 @@ implementation {
   error_t resend( bool cca );
   void loadTXFIFO();
   void attemptSend();
-  void securityCheck();
   void congestionBackoff();
   error_t acquireSpiResource();
   error_t releaseSpiResource();
@@ -550,7 +552,9 @@ implementation {
         return FAIL;
       }
       
+#ifdef CC2420_HW_SECURITY
       securityChecked = 0;
+#endif
       m_state = S_LOAD;
       m_cca = cca;
       m_msg = p_msg;