]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- fixed an issue with the beacon sequence number being set incorrectly
authorjanhauer <janhauer>
Tue, 5 Jan 2010 16:41:16 +0000 (16:41 +0000)
committerjanhauer <janhauer>
Tue, 5 Jan 2010 16:41:16 +0000 (16:41 +0000)
- fixed an issue with indirect transmissions (frame was not allocated properly)
- added some debug info

tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/PollP.nc
tos/lib/mac/tkn154/RadioControlImplP.nc

index 64611920237df53da51b1ac726489924ddbc7677..7ddc5a284746da7e24372e5a2d1378fa4d4e43f4 100644 (file)
@@ -347,7 +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();
+    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] = call MLME_GET.macBSN() + 1;
     offset = MHR_INDEX_ADDRESS;
     *((nxle_uint16_t*) &m_beaconFrame.header->mhr[offset]) = m_updatePANId;
     offset += sizeof(ieee154_macPANId_t);
@@ -562,7 +562,7 @@ implementation
 
   task void txDoneTask()
   {
-    call MLME_SET.macBSN(m_beaconFrame.header->mhr[MHR_INDEX_SEQNO]+1);
+    call MLME_SET.macBSN(m_beaconFrame.header->mhr[MHR_INDEX_SEQNO]);
     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, 
@@ -721,7 +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();
+    m_beaconFrame.header->mhr[MHR_INDEX_SEQNO] = call MLME_GET.macBSN() + 1;
 
     atomic {
       // (4) try to update beacon payload 
index e44f7106b8eedc98d263d231825a2a51c95753e0..3b5c83aa0f3b3037e99d83b4ea53607f2d6cc23f 100644 (file)
@@ -64,7 +64,7 @@ implementation
   };
   int m_numPending;
   uint8_t m_dataRequestCmdID = CMD_FRAME_DATA_REQUEST;
-  void buildDataRequestFrame( uint8_t destAddrMode, uint16_t destPANId,
+  void assembleDataRequestFrame( uint8_t destAddrMode, uint16_t destPANId,
       uint8_t* DstAddr, uint8_t srcAddrMode, ieee154_txframe_t *txFrame);
 
   command error_t Init.init()
@@ -105,7 +105,7 @@ implementation
       txFrame->handle = HANDLE_MLME_POLL_REQUEST;
       if (call MLME_GET.macShortAddress() >= 0xFFFE)
         srcAddrMode = 3;
-      buildDataRequestFrame(coordAddrMode, coordPANID, coordAddressLE, srcAddrMode, txFrame);
+      assembleDataRequestFrame(coordAddrMode, coordPANID, coordAddressLE, srcAddrMode, txFrame);
       if ((status = call PollTx.transmit(txFrame)) != IEEE154_SUCCESS) {
         call TxFramePool.put(txFrame);
         call TxControlPool.put(txControl);
@@ -131,29 +131,29 @@ implementation
       signal DataRequest.pollDone[client]();
       return IEEE154_SUCCESS;
     } else if ((txFrame = call TxFramePool.get()) != NULL) {
-      if ((txControl = call TxControlPool.get()) != NULL)
-        call TxFramePool.put(txFrame);
-      else {
+      if ((txControl = call TxControlPool.get()) != NULL) {
         txFrame->header = &txControl->header;
         txFrame->metadata = &txControl->metadata;
         txFrame->handle = client;
-        buildDataRequestFrame(CoordAddrMode, CoordPANId, 
+        assembleDataRequestFrame(CoordAddrMode, CoordPANId, 
             CoordAddressLE, srcAddrMode, txFrame);
         if ((status = call PollTx.transmit(txFrame)) != IEEE154_SUCCESS) {
           call TxControlPool.put(txControl);
           call TxFramePool.put(txFrame);
-          dbg_serial("PollP", "Overflow\n");
+          dbg_serial("PollP", "Tx Overflow\n");
         } else 
           m_numPending++;
-      }
+      } else {
+        call TxFramePool.put(txFrame);
+      } 
     }
+    dbg_serial("PollP", "Status %lu, numPending: %lu\n", (uint32_t) status, (uint32_t) m_numPending);
     if (status != IEEE154_SUCCESS)
       signal DataRequest.pollDone[client]();
-    dbg_serial("PollP", "Status %lu, numPending: %lu\n", (uint32_t) status, (uint32_t) m_numPending);
     return status;
   }
 
-  void buildDataRequestFrame(uint8_t destAddrMode, uint16_t destPANId,
+  void assembleDataRequestFrame(uint8_t destAddrMode, uint16_t destPANId,
       uint8_t* destAddrPtrLE, uint8_t srcAddrMode, ieee154_txframe_t *txFrame)
   {
     // destAddrPtrLE points to an address in little-endian format !
index 57dc48ac0b899c70cd718f4b1e0f79ae615d7f18..afafb8ccfbdde5103492ee244663be4ce808d682 100644 (file)
@@ -78,9 +78,14 @@ implementation
   event message_t* PhyRx.received(message_t *msg, const ieee154_timestamp_t *timestamp)
   {
     uint8_t *mhr = MHR(msg);
+
+    dbg("RadioControlImplP", "Received frame, DSN: %lu, type: 0x%lu\n", 
+        (uint32_t) mhr[MHR_INDEX_SEQNO], (uint32_t) mhr[MHR_INDEX_FC1] & FC1_FRAMETYPE_MASK);
+
     if (((mhr[1] & FC2_FRAME_VERSION_MASK) > FC2_FRAME_VERSION_1)
         && (!call RadioPromiscuousMode.get()))
       return msg;
+
 #ifndef IEEE154_SECURITY_ENABLED
     if ((mhr[0] & FC1_SECURITY_ENABLED)
         && (!call RadioPromiscuousMode.get()))