]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
some cosmetic changes
authorjanhauer <janhauer>
Thu, 28 May 2009 09:52:54 +0000 (09:52 +0000)
committerjanhauer <janhauer>
Thu, 28 May 2009 09:52:54 +0000 (09:52 +0000)
tos/lib/mac/tkn154/BeaconRequestRxP.nc
tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/TKN154_MAC.h

index dec823a145ae9ce4f6b61529957e9fd9dcee56ab..11adf0ef5bde78c3cbb809a41ceb6219961c60d9 100644 (file)
@@ -106,18 +106,18 @@ implementation
     m_beaconFrame.headerLen = offset;
 
     // Superframe-spec
-    m_payload[0] = 0xff; // beacon- and superframe order always 15 in non-beaconenabled mode
-    m_payload[1] = 0x00; 
+    m_payload[BEACON_INDEX_SF_SPEC1] = 0xff; // beacon- and superframe order always 15 in nonbeacon-enabled mode
+    m_payload[BEACON_INDEX_SF_SPEC2] = 0x00; 
     if (call MLME_GET.macPanCoordinator() == TRUE) 
-      m_payload[1] |= 0x40;
+      m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_PAN_COORD;
     if (call MLME_GET.macAssociationPermit() == TRUE) 
-      m_payload[1] |= 0x80;
+      m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_ASSOCIATION_PERMIT;
     if (call MLME_GET.macBattLifeExt() == TRUE) 
-      m_payload[1] |= 0x10;
+      m_payload[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_BATT_LIFE_EXT;
     // GTS-spec
-    m_payload[2] = 0;
-    // Pending-Address-spec
-    m_payload[3] = 0;
+    m_payload[BEACON_INDEX_GTS_SPEC] = 0;
+    // Pending-Address-spec (behind empty single-byte GTS field)
+    m_payload[BEACON_INDEX_GTS_SPEC + 1] = 0;
 
     signal IEEE154TxBeaconPayload.aboutToTransmit(); 
     post sendBeaconTask();
index 252ed5ae2fd9939a16d3e311a8d5c97d9a483672..24dd305573474f271a6e48abca5b79f76d215c33 100644 (file)
@@ -526,17 +526,21 @@ implementation
     }
 
     // update superframe-related variables
-    m_numGtsSlots = (frame->payload[2] & 0x07);
+    m_numGtsSlots = 
+      (frame->payload[BEACON_INDEX_GTS_SPEC] & GTS_DESCRIPTOR_COUNT_MASK) >> GTS_DESCRIPTOR_COUNT_OFFSET;
     gtsFieldLength = 1 + ((m_numGtsSlots > 0) ? 1 + m_numGtsSlots * 3: 0);
-    m_numCapSlots = (frame->payload[1] & 0x0F) + 1;
-    m_sfSlotDuration = (((uint32_t) 1) << ((frame->payload[0] & 0xF0) >> 4)) * IEEE154_aBaseSlotDuration;
+    m_numCapSlots = 
+      ((frame->payload[BEACON_INDEX_SF_SPEC2] & SF_SPEC2_FINAL_CAPSLOT_MASK) >> SF_SPEC2_FINAL_CAPSLOT_OFFSET) + 1;
+    m_sfSlotDuration = 
+      (((uint32_t) 1) << ((frame->payload[BEACON_INDEX_SF_SPEC1] & SF_SPEC1_SO_MASK) >> SF_SPEC1_SO_OFFSET)) * 
+      IEEE154_aBaseSlotDuration;
 
-    if (frame->header->mhr[0] & FC1_FRAME_PENDING)
+    if (frame->header->mhr[MHR_INDEX_FC1] & FC1_FRAME_PENDING)
       m_framePendingBit = TRUE;
     else
       m_framePendingBit = FALSE;
-    memcpy(m_gtsField, &frame->payload[2], gtsFieldLength);
-    if (frame->payload[1] & 0x10) {
+    memcpy(m_gtsField, &frame->payload[BEACON_INDEX_GTS_SPEC], gtsFieldLength);
+    if (frame->payload[BEACON_INDEX_SF_SPEC2] & SF_SPEC2_BATT_LIFE_EXT) {
       // BLE is active; calculate the time offset from slot 0
       m_battLifeExtDuration = IEEE154_SHR_DURATION + 
         (frame->headerLen + frame->payloadLen + 2) * IEEE154_SYMBOLS_PER_OCTET; 
@@ -649,7 +653,7 @@ implementation
   uint8_t getNumGtsSlots(uint8_t *gtsInfoField)
   {
     uint8_t i, num=0;
-    for (i=0; i<(gtsInfoField[0] & GTS_DESCRIPTOR_COUNT_MASK); i++)
+    for (i=0; i<((gtsInfoField[0] & GTS_DESCRIPTOR_COUNT_MASK) >> GTS_DESCRIPTOR_COUNT_OFFSET); i++)
       num += ((gtsInfoField[4+i*3] & GTS_LENGTH_MASK) >> GTS_LENGTH_OFFSET);
     return num;
   }
@@ -699,13 +703,15 @@ implementation
       // (3) update SF spec
       beaconSpecs -= 2; // sizeof SF Spec
       if (m_payloadState & MODIFIED_SF_SPEC) {
-        beaconSpecs[0] = m_beaconOrder | (m_superframeOrder << 4);
-        beaconSpecs[1] = 0;
+        beaconSpecs[BEACON_INDEX_SF_SPEC1] = 
+          (m_beaconOrder << SF_SPEC1_BO_OFFSET) | (m_superframeOrder << SF_SPEC1_SO_OFFSET);
+        beaconSpecs[BEACON_INDEX_SF_SPEC2] = 0;
         if (call MLME_GET.macAssociationPermit())
-          beaconSpecs[1] |= SF_SPEC2_ASSOCIATION_PERMIT;        
+          beaconSpecs[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_ASSOCIATION_PERMIT;        
         if (call MLME_GET.macPanCoordinator())
-          beaconSpecs[1] |= SF_SPEC2_PAN_COORD;
-        beaconSpecs[1] |= ((15-numGtsSlots) & 0x0F); // update FinalCAPSlot field
+          beaconSpecs[BEACON_INDEX_SF_SPEC2] |= SF_SPEC2_PAN_COORD;
+        beaconSpecs[BEACON_INDEX_SF_SPEC2] |= 
+          ((15-numGtsSlots) & SF_SPEC2_FINAL_CAPSLOT_MASK);
       }
       m_beaconFrame.payloadLen = (m_pendingAddrLen + m_pendingGtsLen + 2) + m_beaconPayloadLen;
       m_beaconFrame.payload = beaconSpecs;
index f7544e0788f10ba20dc533e44bf03380f36a8bf1..f1e301ed75bf685195215603987764f5d175e93e 100644 (file)
@@ -240,10 +240,19 @@ enum {
   BEACON_INDEX_SF_SPEC2 = 1,
   BEACON_INDEX_GTS_SPEC = 2,
 
+  SF_SPEC1_BO_MASK = 0x0F,
+  SF_SPEC1_BO_OFFSET = 0,
+  SF_SPEC1_SO_MASK = 0xF0,
+  SF_SPEC1_SO_OFFSET = 4,
+
+  SF_SPEC2_FINAL_CAPSLOT_MASK = 0x0F,
+  SF_SPEC2_FINAL_CAPSLOT_OFFSET = 0,
+  SF_SPEC2_BATT_LIFE_EXT = 0x10,
   SF_SPEC2_PAN_COORD = 0x40,
   SF_SPEC2_ASSOCIATION_PERMIT = 0x80,
 
   GTS_DESCRIPTOR_COUNT_MASK = 0x07,
+  GTS_DESCRIPTOR_COUNT_OFFSET = 0,
   GTS_LENGTH_MASK = 0xF0,
   GTS_LENGTH_OFFSET = 4,
   GTS_SPEC_PERMIT = 0x80,