]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
The beacon sequence number can now be modified by the next higher layer through a...
authorjanhauer <janhauer>
Mon, 14 Dec 2009 16:46:49 +0000 (16:46 +0000)
committerjanhauer <janhauer>
Mon, 14 Dec 2009 16:46:49 +0000 (16:46 +0000)
tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc
tos/lib/mac/tkn154/dummies/NoBeaconTransmitP.nc

index 24dd305573474f271a6e48abca5b79f76d215c33..64611920237df53da51b1ac726489924ddbc7677 100644 (file)
@@ -74,6 +74,7 @@ module BeaconTransmitP
     interface GetSet<ieee154_txframe_t*> as GetSetRealignmentFrame;
     interface GetNow<bool> as IsBroadcastReady; 
     interface TimeCalc;
+    interface Random;
     interface Leds;
   }
 }
@@ -92,7 +93,6 @@ implementation
   norace uint32_t m_beaconInterval;
   norace uint32_t m_previousBeaconInterval;
   norace uint32_t m_dt;
-  norace uint8_t m_bsn;
   norace uint32_t m_lastBeaconTxTime;
   norace ieee154_timestamp_t m_lastBeaconTxRefTime;
   norace ieee154_macBattLifeExtPeriods_t m_battLifeExtPeriods;
@@ -160,6 +160,8 @@ implementation
   {
     // reset this component, will only be called while we're not owning the token
     // TODO: check to signal MLME_START.confirm ?
+
+    call MLME_SET.macBSN(call Random.rand16());
     m_beaconFrame.header = &m_header;
     m_beaconFrame.headerLen = 0;
     m_beaconFrame.payload = m_payload;
@@ -329,7 +331,6 @@ implementation
     }
     m_dt = m_beaconInterval;
     m_txState = S_TX_IDLE;
-    m_bsn = call MLME_GET.macBSN()+1;
     m_battLifeExtPeriods = call MLME_GET.macBattLifeExtPeriods();
 
     // (3) update PIB
@@ -346,6 +347,7 @@ implementation
     isShortAddr = (shortAddress != 0xFFFE);
     m_beaconFrame.header->mhr[MHR_INDEX_FC1] = FC1_FRAMETYPE_BEACON;
     m_beaconFrame.header->mhr[MHR_INDEX_FC2] = isShortAddr ? FC2_SRC_MODE_SHORT : FC2_SRC_MODE_EXTENDED;
+    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] = call MLME_GET.macBSN();
     offset = MHR_INDEX_ADDRESS;
     *((nxle_uint16_t*) &m_beaconFrame.header->mhr[offset]) = m_updatePANId;
     offset += sizeof(ieee154_macPANId_t);
@@ -492,7 +494,6 @@ implementation
     else
       m_beaconFrame.header->mhr[MHR_INDEX_FC1] &= ~FC1_FRAME_PENDING;
 
-    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] = m_bsn; // update beacon seqno
     if (m_txOneBeaconImmediately) {
       m_txOneBeaconImmediately = FALSE;
       timestamp = NULL;
@@ -561,7 +562,8 @@ implementation
 
   task void txDoneTask()
   {
-    call MLME_SET.macBSN(m_bsn++);
+    call MLME_SET.macBSN(m_beaconFrame.header->mhr[MHR_INDEX_SEQNO]+1);
+    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] += 1; // may be overwritten by the next higher layer
     call SetMacBeaconTxTime.set(m_lastBeaconTxTime); // start of slot0, ie. first preamble byte of beacon
     call BeaconPayloadUpdateTimer.startOneShotAt(m_lastBeaconTxTime, 
         (m_beaconInterval>BEACON_PAYLOAD_UPDATE_INTERVAL) ? (m_beaconInterval - BEACON_PAYLOAD_UPDATE_INTERVAL): 0);
@@ -719,6 +721,7 @@ implementation
     } // end atomic (give BeaconSendAlarm.fired() the chance to execute)
 
     signal IEEE154TxBeaconPayload.aboutToTransmit();
+    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] = call MLME_GET.macBSN();
 
     atomic {
       // (4) try to update beacon payload 
index 1176a1d2baa5fec7f00c72fc39ab3192a7d39563..87f7f6b21d18c3046293233b703683d7ac4315e3 100644 (file)
@@ -266,6 +266,7 @@ implementation
   BeaconTransmitP.GetSetRealignmentFrame -> CoordRealignmentP;
   BeaconTransmitP.IsBroadcastReady -> CoordBroadcastP.IsBroadcastReady;
   BeaconTransmitP.TimeCalc -> PibP;
+  BeaconTransmitP.Random = Random;
   BeaconTransmitP.Leds = Leds;
 
   /* ------------------ Beacon Tracking (MLME-SYNC) ------------------ */
index 04f4a8997e882ec82e4aa0fca0ad78836c15ab61..673adbb1d4726919311b466807d7a36fe16a60f3 100644 (file)
@@ -71,6 +71,7 @@ module NoBeaconTransmitP
     interface GetSet<ieee154_txframe_t*> as GetSetRealignmentFrame;
     interface GetNow<bool> as IsBroadcastReady; 
     interface TimeCalc;
+    interface Random;
     interface Leds;
   }
 }