]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/chips/cc1000/CC1000SendReceiveP.nc
Merge over into the trunk.
[tinyos-2.x.git] / tos / chips / cc1000 / CC1000SendReceiveP.nc
index ec2e8513b360658418f0b97169a959bac39fc896..e4e4d77d9d95ac26eefc87d5682404fb74615e62 100644 (file)
@@ -262,7 +262,7 @@ implementation
          txBufPtr = msg;
        }
       }
-    signal ByteRadio.rts();
+    signal ByteRadio.rts(msg);
 
     return SUCCESS;
   }
@@ -476,22 +476,18 @@ implementation
     cc1000_metadata_t *rxMetadata = getMetadata(rxBufPtr);
 
     if (result != SUCCESS)
-      rxMetadata->strength = 0;
+      rxMetadata->strength_or_preamble = 0;
     else
-      rxMetadata->strength = data;
+      rxMetadata->strength_or_preamble = data;
   }
 
   void rxData(uint8_t in) {
     uint8_t nextByte;
     cc1000_header_t *rxHeader = getHeader(rxBufPtr);
-
-    // rxLength is the offset into a message_t at which the packet
-    // data ends: it is NOT equal to the number of bytes received,
-    // as there may be padding in the message_t before the packet.
-    uint8_t rxLength = rxHeader->length + offsetof(message_t, data);
+    uint8_t rxLength = rxHeader->length;
 
     // Reject invalid length packets
-    if (rxLength > TOSH_DATA_LENGTH + offsetof(message_t, data))
+    if (rxLength > TOSH_DATA_LENGTH)
       {
        // The packet's screwed up, so just dump it
        enterListenState();
@@ -503,6 +499,8 @@ implementation
     nextByte = rxShiftBuf >> f.rxBitOffset;
     ((uint8_t *)rxBufPtr)[count++] = nextByte;
 
+    // Adjust rxLength to correspond to the corresponding offset in message_t
+    rxLength += offsetof(message_t, data);
     if (count <= rxLength)
       runningCrc = crcByte(runningCrc, nextByte);
 
@@ -524,7 +522,7 @@ implementation
 
     if (f.ack &&
        rxFooter->crc &&
-       rxHeader->addr == call amAddress())
+       rxHeader->dest == call amAddress())
       {
        enterAckState();
        call CC1000Control.txMode();