]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
* Removed hardware address recognition to monitor its affect on unit tests, low power...
authorrincon <rincon>
Wed, 14 May 2008 21:33:07 +0000 (21:33 +0000)
committerrincon <rincon>
Wed, 14 May 2008 21:33:07 +0000 (21:33 +0000)
* Implemented software-based address recognition in ReceiveP.
* Applied Steve Dawson-Haggerty's patch to make the RadioBackoff interface parameterized by AM ID only at the top of the stack, whiich allows stack modifications that do not support AM ID's to exist below the active message layer.

tos/chips/cc2420/CC2420.h
tos/chips/cc2420/CC2420ActiveMessageC.nc
tos/chips/cc2420/CC2420ActiveMessageP.nc
tos/chips/cc2420/control/CC2420ControlP.nc
tos/chips/cc2420/csma/CC2420CsmaC.nc
tos/chips/cc2420/csma/CC2420CsmaP.nc
tos/chips/cc2420/lpl/DefaultLplP.nc
tos/chips/cc2420/receive/CC2420ReceiveP.nc

index 6a9d4f3a14dec1409c597d7b101f431e46a26d17..83cee7c283bafc0db47e8dcc5e02f44de3d40ec1 100644 (file)
@@ -55,7 +55,10 @@ typedef nx_struct cc2420_header_t {
   nxle_uint8_t network;
 #endif
 
+#ifndef TINYOS_IP
   nxle_uint8_t type;
+#endif
+
 } cc2420_header_t;
   
 /**
index b69861cb1d09275915e4f785ff16c66e20321bee..f39f1b7ae8a8fd99bb0a37a379b794abc47c9d11 100644 (file)
@@ -78,7 +78,7 @@ implementation {
 #endif
 
   
-  RadioBackoff = CsmaC;
+  RadioBackoff = AM;
   Packet = AM;
   AMSend = AM;
   SendNotifier = AM;
@@ -113,4 +113,6 @@ implementation {
   AM.CC2420PacketBody -> CC2420PacketC;
   AM.CC2420Config -> CC2420ControlC;
   
+  AM.SubBackoff -> CsmaC;
+  
 }
index 35fb1c03345e4b5bdc4f542965613fe9a2de18e0..d6a6fbd09466c775e56b74a8b92295d260370179 100644 (file)
@@ -42,6 +42,7 @@ module CC2420ActiveMessageP {
     interface AMPacket;
     interface Packet;
     interface SendNotifier[am_id_t id];
+    interface RadioBackoff[am_id_t id];
   }
   
   uses {
@@ -51,6 +52,7 @@ module CC2420ActiveMessageP {
     interface CC2420PacketBody;
     interface CC2420Config;
     interface ActiveMessageAddress;
+    interface RadioBackoff as SubBackoff;
   }
 }
 implementation {
@@ -67,6 +69,7 @@ implementation {
     header->type = id;
     header->dest = addr;
     header->destpan = call CC2420Config.getPanAddr();
+    header->src = call AMPacket.address();
     
     signal SendNotifier.aboutToSend[id](addr, msg);
     
@@ -192,6 +195,48 @@ implementation {
   event void CC2420Config.syncDone( error_t error ) {
   }
   
+  
+  /***************** RadioBackoff ***********************/
+
+  async event void SubBackoff.requestInitialBackoff(message_t *msg) {
+    signal RadioBackoff.requestInitialBackoff[((cc2420_header_t*)(msg->data - 
+                                        sizeof(cc2420_header_t)))->type](msg);
+  }
+
+  async event void SubBackoff.requestCongestionBackoff(message_t *msg) {
+    signal RadioBackoff.requestCongestionBackoff[((cc2420_header_t*)(msg->data - 
+        sizeof(cc2420_header_t)))->type](msg);
+  }
+  async event void SubBackoff.requestCca(message_t *msg) {
+    // Lower layers than this do not configure the CCA settings
+    signal RadioBackoff.requestCca[((cc2420_header_t*)(msg->data - 
+        sizeof(cc2420_header_t)))->type](msg);
+  }
+
+  async command void RadioBackoff.setInitialBackoff[am_id_t amId](uint16_t backoffTime) {
+    call SubBackoff.setInitialBackoff(backoffTime);
+  }
+  
+  /**
+   * Must be called within a requestCongestionBackoff event
+   * @param backoffTime the amount of time in some unspecified units to backoff
+   */
+  async command void RadioBackoff.setCongestionBackoff[am_id_t amId](uint16_t backoffTime) {
+    call SubBackoff.setCongestionBackoff(backoffTime);
+  }
+
+      
+  /**
+   * Enable CCA for the outbound packet.  Must be called within a requestCca
+   * event
+   * @param ccaOn TRUE to enable CCA, which is the default.
+   */
+  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) {
     return msg;
@@ -206,5 +251,16 @@ implementation {
 
   default event void SendNotifier.aboutToSend[am_id_t amId](am_addr_t addr, message_t *msg) {
   }
+  default async event void RadioBackoff.requestInitialBackoff[am_id_t id](
+      message_t *msg) {
+  }
+
+  default async event void RadioBackoff.requestCongestionBackoff[am_id_t id](
+      message_t *msg) {
+  }
+  
+  default async event void RadioBackoff.requestCca[am_id_t id](
+      message_t *msg) {
+  }
   
 }
index 4ea1382e44e753d18bb8d1bdd49e4ff780c23742..7d44f731d551661581dc0f344e54f346185cecd6 100644 (file)
@@ -437,11 +437,14 @@ implementation {
 
   /**
    * Write the MDMCTRL0 register
+   * Disabling hardware address recognition improves acknowledgment success
+   * rate and low power communications reliability by causing the local node
+   * to do work while the real destination node of the packet is acknowledging.
    */
   void writeMdmctrl0() {
     atomic {
       call MDMCTRL0.write( ( 1 << CC2420_MDMCTRL0_RESERVED_FRAME_MODE ) |
-          ( addressRecognition << CC2420_MDMCTRL0_ADR_DECODE ) |
+          ( 0 << CC2420_MDMCTRL0_ADR_DECODE ) |
           ( 2 << CC2420_MDMCTRL0_CCA_HYST ) |
           ( 3 << CC2420_MDMCTRL0_CCA_MOD ) |
           ( 1 << CC2420_MDMCTRL0_AUTOCRC ) |
index 7e8dd5121f0b4e0245ca47275db1ee113cf87283..74ba75332002e0f8058508898eaf1cfd70655222 100644 (file)
@@ -44,7 +44,7 @@ configuration CC2420CsmaC {
   provides interface SplitControl;
   provides interface Send;
   provides interface Receive;
-  provides interface RadioBackoff[am_id_t amId];
+  provides interface RadioBackoff;
 
 }
 
@@ -55,9 +55,6 @@ implementation {
   SplitControl = CsmaP;
   Send = CsmaP;
   
-  components CC2420ActiveMessageC;
-  CsmaP.AMPacket -> CC2420ActiveMessageC;
-  
   components CC2420ControlC;
   CsmaP.Resource -> CC2420ControlC;
   CsmaP.CC2420Power -> CC2420ControlC;
index 9dada4cae5bacfa9ae302ffb80791bad03da1e61..64a9852433ae71fd685d0359665dd2437d0ef8d8 100644 (file)
@@ -38,7 +38,7 @@ module CC2420CsmaP {
 
   provides interface SplitControl;
   provides interface Send;
-  provides interface RadioBackoff[am_id_t amId];
+  provides interface RadioBackoff;
 
   uses interface Resource;
   uses interface CC2420Power;
@@ -46,7 +46,6 @@ module CC2420CsmaP {
   uses interface CC2420Transmit;
   uses interface RadioBackoff as SubBackoff;
   uses interface Random;
-  uses interface AMPacket;
   uses interface Leds;
   uses interface CC2420Packet;
   uses interface CC2420PacketBody;
@@ -141,15 +140,15 @@ implementation {
                     ( 1 << IEEE154_FCF_INTRAPAN ) |
                     ( IEEE154_ADDR_SHORT << IEEE154_FCF_DEST_ADDR_MODE ) |
                     ( IEEE154_ADDR_SHORT << IEEE154_FCF_SRC_ADDR_MODE ) );
-    header->src = call AMPacket.address();
+
     metadata->ack = FALSE;
     metadata->rssi = 0;
     metadata->lqi = 0;
     metadata->time = 0;
     
     ccaOn = TRUE;
-    signal RadioBackoff.requestCca[((cc2420_header_t*)(m_msg->data - 
-        sizeof(cc2420_header_t)))->type](m_msg);
+    signal RadioBackoff.requestCca(m_msg);
+
     call CC2420Transmit.send( m_msg, ccaOn );
     return SUCCESS;
 
@@ -173,7 +172,7 @@ implementation {
    * Must be called within a requestInitialBackoff event
    * @param backoffTime the amount of time in some unspecified units to backoff
    */
-  async command void RadioBackoff.setInitialBackoff[am_id_t amId](uint16_t backoffTime) {
+  async command void RadioBackoff.setInitialBackoff(uint16_t backoffTime) {
     call SubBackoff.setInitialBackoff(backoffTime);
   }
   
@@ -181,7 +180,7 @@ implementation {
    * Must be called within a requestCongestionBackoff event
    * @param backoffTime the amount of time in some unspecified units to backoff
    */
-  async command void RadioBackoff.setCongestionBackoff[am_id_t amId](uint16_t backoffTime) {
+  async command void RadioBackoff.setCongestionBackoff(uint16_t backoffTime) {
     call SubBackoff.setCongestionBackoff(backoffTime);
   }
       
@@ -190,7 +189,7 @@ implementation {
    * event
    * @param ccaOn TRUE to enable CCA, which is the default.
    */
-  async command void RadioBackoff.setCca[am_id_t amId](bool useCca) {
+  async command void RadioBackoff.setCca(bool useCca) {
     ccaOn = useCca;
   }
   
@@ -218,20 +217,19 @@ implementation {
     call SubBackoff.setInitialBackoff ( call Random.rand16() 
         % (0x1F * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
         
-    signal RadioBackoff.requestInitialBackoff[((cc2420_header_t*)(msg->data - 
-        sizeof(cc2420_header_t)))->type](msg);
+    signal RadioBackoff.requestInitialBackoff(msg);
   }
 
   async event void SubBackoff.requestCongestionBackoff(message_t *msg) {
     call SubBackoff.setCongestionBackoff( call Random.rand16() 
         % (0x7 * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
 
-    signal RadioBackoff.requestCongestionBackoff[((cc2420_header_t*)(msg->data - 
-        sizeof(cc2420_header_t)))->type](msg);
+    signal RadioBackoff.requestCongestionBackoff(msg);
   }
   
   async event void SubBackoff.requestCca(message_t *msg) {
     // Lower layers than this do not configure the CCA settings
+    signal RadioBackoff.requestCca(msg);
   }
   
   
@@ -280,17 +278,15 @@ implementation {
   default event void SplitControl.stopDone(error_t error) {
   }
   
-  
-  default async event void RadioBackoff.requestInitialBackoff[am_id_t amId](
-      message_t *msg) {
+  default async event void RadioBackoff.requestInitialBackoff(message_t *msg) {
   }
 
-  default async event void RadioBackoff.requestCongestionBackoff[am_id_t amId](
-      message_t *msg) {
+  default async event void RadioBackoff.requestCongestionBackoff(message_t *msg) {
   }
   
-  default async event void RadioBackoff.requestCca[am_id_t amId](
-      message_t *msg) {
+  default async event void RadioBackoff.requestCca(message_t *msg) {
   }
+  
+  
 }
 
index 1a68ec15c03a5699739e79a64f2dbeb843622caf..d93debb0fa79192c262359b0ecc7c6499df36a5d 100644 (file)
@@ -54,7 +54,7 @@ module DefaultLplP {
   uses {
     interface Send as SubSend;
     interface CC2420Transmit as Resend;
-    interface RadioBackoff[am_id_t amId];
+    interface RadioBackoff;
     interface Receive as SubReceive;
     interface AMPacket;
     interface SplitControl as SubControl;
@@ -283,7 +283,7 @@ implementation {
       return SUCCESS;
     }
     
-    return FAIL;
+    return EBUSY;
   }
 
   command error_t Send.cancel(message_t *msg) {
@@ -308,23 +308,23 @@ implementation {
   
   
   /***************** RadioBackoff Events ****************/
-  async event void RadioBackoff.requestInitialBackoff[am_id_t amId](message_t *msg) {
+  async event void RadioBackoff.requestInitialBackoff(message_t *msg) {
     if((call CC2420PacketBody.getMetadata(msg))->rxInterval 
         > ONE_MESSAGE) {
-      call RadioBackoff.setInitialBackoff[amId]( call Random.rand16() 
+      call RadioBackoff.setInitialBackoff( call Random.rand16() 
           % (0x4 * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
     }
   }
   
-  async event void RadioBackoff.requestCongestionBackoff[am_id_t amId](message_t *msg) {
+  async event void RadioBackoff.requestCongestionBackoff(message_t *msg) {
     if((call CC2420PacketBody.getMetadata(msg))->rxInterval 
         > ONE_MESSAGE) {
-      call RadioBackoff.setCongestionBackoff[amId]( call Random.rand16() 
+      call RadioBackoff.setCongestionBackoff( call Random.rand16() 
           % (0x3 * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
     }
   }
   
-  async event void RadioBackoff.requestCca[am_id_t amId](message_t *msg) {
+  async event void RadioBackoff.requestCca(message_t *msg) {
   }
   
 
index a85b62e8a2fbaa441216f1d37d363e5c498be059..4a5d1ad717a47d6bd37c66a4926b10713e26c8ec 100644 (file)
@@ -37,6 +37,8 @@
  */
 
 #include "IEEE802154.h"
+#include "message.h"
+#include "AM.h"
 
 module CC2420ReceiveP {
 
@@ -107,6 +109,7 @@ implementation {
   void receive();
   void waitForNextPacket();
   void flush();
+  bool passesAddressCheck(message_t *msg);
   
   task void receiveDone_task();
   
@@ -326,9 +329,12 @@ implementation {
     metadata->crc = buf[ rxFrameLength ] >> 7;
     metadata->lqi = buf[ rxFrameLength ] & 0x7f;
     metadata->rssi = buf[ rxFrameLength - 1 ];
-    m_p_rx_buf = signal Receive.receive( m_p_rx_buf, m_p_rx_buf->data, 
-                                         rxFrameLength );
-
+    
+    if(passesAddressCheck(m_p_rx_buf)) {
+      m_p_rx_buf = signal Receive.receive( m_p_rx_buf, m_p_rx_buf->data, 
+          rxFrameLength );
+    }
+    
     atomic receivingPacket = FALSE;
     waitForNextPacket();
   }
@@ -432,4 +438,16 @@ implementation {
     m_missed_packets = 0;
   }
 
+  /**
+   * @return TRUE if the given message passes address recognition
+   */
+  bool passesAddressCheck(message_t *msg) {
+    cc2420_header_t *header = call CC2420PacketBody.getHeader( msg );
+    
+    if(!(call CC2420Config.isAddressRecognitionEnabled())) {
+      return TRUE;
+    } 
+    
+    return (header->dest == call CC2420Config.getShortAddr());
+  }
 }