]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
- fixed an issue with indirect transmissions (timeout wasn't set correctly)
authorjanhauer <janhauer>
Tue, 5 May 2009 16:56:12 +0000 (16:56 +0000)
committerjanhauer <janhauer>
Tue, 5 May 2009 16:56:12 +0000 (16:56 +0000)
- added some debug output

tos/lib/mac/tkn154/AssociateP.nc
tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc
tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc
tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc

index 11f96f0d492a40eb9338e1449e4a49bed31f6142..f631f65cb358eb8164bf3ab98be501a56c724a93 100644 (file)
@@ -175,6 +175,7 @@ implementation
     if (!m_associationOngoing)
       return;
     // have not received an AssociationResponse yet, poll the coordinator now
+    dbg_serial("AssociationP", "Polling the coordinator for an AssociationResponse now...\n");
     if (m_coordAddrMode == ADDR_MODE_SHORT_ADDRESS)
       *((nxle_uint16_t*) &coordAddress) = call MLME_GET.macCoordShortAddress();
     else
@@ -184,6 +185,7 @@ implementation
       m_shortAddress = 0xFFFF;
       m_assocRespStatus = IEEE154_TRANSACTION_OVERFLOW;
       signal DataRequest.pollDone();
+      dbg_serial("AssociationP", "Poll failed (locally)...\n");
     }
   }
 
index 7709ae8f63342eab1f0f494c89ff279e08d5e3b1..ca1abef292ce7073ba6a97380e1795a0751c1f48 100644 (file)
@@ -71,8 +71,7 @@ generic module DispatchSlottedCsmaP(uint8_t sfDirection)
   {
     interface Alarm<TSymbolIEEE802154,uint32_t> as CapEndAlarm;
     interface Alarm<TSymbolIEEE802154,uint32_t> as BLEAlarm;
-    interface Alarm<TSymbolIEEE802154,uint32_t> as IndirectTxWaitAlarm;
-    interface Alarm<TSymbolIEEE802154,uint32_t> as BroadcastAlarm;
+    interface Alarm<TSymbolIEEE802154,uint32_t> as RxWaitAlarm;
     interface TransferableResource as RadioToken;
     interface SuperframeStructure; 
     interface GetNow<token_requested_t> as IsRadioTokenRequested;
@@ -138,7 +137,7 @@ implementation
 
   /* function / task prototypes */
   void stopAllAlarms();
-  next_state_t tryReceive(rx_alarm_t alarmType);
+  next_state_t tryReceive();
   next_state_t tryTransmit();
   next_state_t trySwitchOff();
   void backupCurrentFrame();
@@ -181,6 +180,7 @@ implementation
     if (m_bcastFrame)
       signalTxBroadcastDone(m_bcastFrame, IEEE154_TRANSACTION_OVERFLOW);
     m_currentFrame = m_lastFrame = m_bcastFrame = NULL;
+    m_macMaxFrameTotalWaitTime = call MLME_GET.macMaxFrameTotalWaitTime();
     stopAllAlarms();
     return SUCCESS;
   }
@@ -313,10 +313,8 @@ implementation
   void stopAllAlarms()
   {
     call CapEndAlarm.stop();
-    if (DEVICE_ROLE) {
-      call IndirectTxWaitAlarm.stop();
-      call BroadcastAlarm.stop();
-    }
+    if (DEVICE_ROLE)
+      call RxWaitAlarm.stop();
     call BLEAlarm.stop();
   }
 
@@ -354,7 +352,7 @@ implementation
         if (call RadioOff.isOff()) {
           stopAllAlarms();  // may still fire, but is locked through isOwner()
           if (DEVICE_ROLE && m_indirectTxPending)
-            signal IndirectTxWaitAlarm.fired();
+            signal RxWaitAlarm.fired();
           m_broadcastRxPending = FALSE;
           if (COORD_ROLE && m_bcastFrame) {
             // didn't manage to transmit a broadcast
@@ -376,7 +374,7 @@ implementation
       else if (DEVICE_ROLE && m_broadcastRxPending) {
         // receive a broadcast from coordinator
         dbg_push_state(2);
-        next = tryReceive(BROADCAST_ALARM);
+        next = tryReceive();
       } else if (COORD_ROLE && m_bcastFrame) {
         dbg_push_state(2);
         next = tryTransmit();
@@ -386,7 +384,7 @@ implementation
       // and are we now waiting for a frame from the coordinator?
       else if (DEVICE_ROLE && m_indirectTxPending) {
         dbg_push_state(3);
-        next = tryReceive(INDIRECT_TX_ALARM);
+        next = tryReceive();
       }
 
       // Check 4: is some other operation (like MLME-SCAN or MLME-RESET) pending? 
@@ -422,7 +420,7 @@ implementation
       // Check 7: should we be in receive mode?
       else if (COORD_ROLE || call IsRxEnableActive.getNow() || macRxOnWhenIdle) {
         dbg_push_state(7);
-        next = tryReceive(NO_ALARM);
+        next = tryReceive();
         if (next == DO_NOTHING) {
           // if there was an active MLME_RX_ENABLE.request then we'll
           // inform the next higher layer that radio is now in Rx mode
@@ -485,7 +483,7 @@ implementation
     return next;
   }
 
-  next_state_t tryReceive(rx_alarm_t alarmType)
+  next_state_t tryReceive()
   {
     next_state_t next;
     if (call RadioRx.isReceiving())
@@ -494,12 +492,6 @@ implementation
       next = SWITCH_OFF;
     else {
       call RadioRx.enableRx(0, 0);
-      switch (alarmType)
-      {
-        case INDIRECT_TX_ALARM: call IndirectTxWaitAlarm.start(m_macMaxFrameTotalWaitTime); break;
-        case BROADCAST_ALARM: call BroadcastAlarm.start(m_macMaxFrameTotalWaitTime); break;
-        case NO_ALARM: break;
-      }
       next = WAIT_FOR_RXDONE;
     }
     return next;
@@ -515,8 +507,19 @@ implementation
     return next;
   }
 
-  async event void RadioOff.offDone() { m_lock = FALSE; updateState();}
-  async event void RadioRx.enableRxDone() { m_lock = FALSE; updateState();}
+  async event void RadioOff.offDone() 
+  { 
+    m_lock = FALSE; 
+    updateState();
+  }
+
+  async event void RadioRx.enableRxDone() 
+  { 
+    if (DEVICE_ROLE && (m_indirectTxPending || m_broadcastRxPending))
+      call RxWaitAlarm.start(m_macMaxFrameTotalWaitTime);
+    m_lock = FALSE; 
+    updateState();
+  }
 
   async event void CapEndAlarm.fired() { 
     dbg_serial("DispatchSlottedCsmaP", "CapEndAlarm.fired()\n");
@@ -524,20 +527,23 @@ implementation
   }
   async event void BLEAlarm.fired() { updateState();}
   event void RxEnableStateChange.notify(bool whatever) { updateState();}
-  async event void BroadcastAlarm.fired() { m_broadcastRxPending = FALSE; updateState();}
   event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) {
     atomic macRxOnWhenIdle = *((ieee154_macRxOnWhenIdle_t*) val);
     updateState();
   }
 
-  async event void IndirectTxWaitAlarm.fired() 
+  async event void RxWaitAlarm.fired() 
   { 
-    atomic {
-      if (m_indirectTxPending) {
-        m_indirectTxPending = FALSE; 
-        post signalTxDoneTask(); 
+    if (DEVICE_ROLE && (m_indirectTxPending || m_broadcastRxPending))
+      atomic {
+        if (m_indirectTxPending) {
+          m_indirectTxPending = FALSE; 
+          post signalTxDoneTask(); 
+        } else if (m_broadcastRxPending) {
+          m_broadcastRxPending = FALSE;
+          updateState();
+        }
       }
-    }
   }
 
   async event void SlottedCsmaCa.transmitDone(ieee154_txframe_t *frame, ieee154_csma_t *csma, 
@@ -650,18 +656,20 @@ implementation
     dbg("DispatchSlottedCsmaP", "Received frame, DSN: %lu, type: 0x%lu\n", 
         (uint32_t) mhr[MHR_INDEX_SEQNO], (uint32_t) frameType);
     atomic {
-      if (DEVICE_ROLE && m_indirectTxPending) {
+      if (DEVICE_ROLE && (m_indirectTxPending || m_broadcastRxPending)) {
         message_t* frameBuf;
-        call IndirectTxWaitAlarm.stop();
-        // TODO: check!
-        //if (frame->payloadLen)
-          // is this frame from our coordinator? hmm... we cannot say/ with
-          // certainty, because we might only know either the  coordinator
-          // extended or short address (and the frame could/ have been sent
-          // with the other addressing mode) ??
+        call RxWaitAlarm.stop();
+        // TODO: check the following: 
+        // is this frame from our coordinator? hmm... we cannot say/ with
+        // certainty, because we might only know either the  coordinator
+        // extended or short address (and the frame could/ have been sent
+        // with the other addressing mode) ??
         m_txStatus = IEEE154_SUCCESS;
-        frameBuf = signal FrameExtracted.received[frameType](frame, m_lastFrame);
-        signal IndirectTxWaitAlarm.fired();
+        if (m_indirectTxPending)
+          frameBuf = signal FrameExtracted.received[frameType](frame, m_lastFrame); // indirect tx from coord
+        else
+          frameBuf = signal FrameRx.received[frameType](frame); // broadcast from coordinator
+        signal RxWaitAlarm.fired();
         return frameBuf;
       } else
         return signal FrameRx.received[frameType](frame);
@@ -720,14 +728,10 @@ implementation
   default event message_t* FrameRx.received[uint8_t client](message_t* data) {return data;}
   default async command bool IsRxEnableActive.getNow() {return FALSE;}
 
-  default async command void IndirectTxWaitAlarm.start(uint32_t dt) {ASSERT(0);}
-  default async command void IndirectTxWaitAlarm.stop() {ASSERT(0);}
-  default async command void IndirectTxWaitAlarm.startAt(uint32_t t0, uint32_t dt) {ASSERT(0);}
+  default async command void RxWaitAlarm.start(uint32_t dt) {ASSERT(0);}
+  default async command void RxWaitAlarm.stop() {ASSERT(0);}
+  default async command void RxWaitAlarm.startAt(uint32_t t0, uint32_t dt) {ASSERT(0);}
   
-  default async command void BroadcastAlarm.start(uint32_t dt) {ASSERT(0);}
-  default async command void BroadcastAlarm.stop() {ASSERT(0);}
-  default async command void BroadcastAlarm.startAt(uint32_t t0, uint32_t dt) {ASSERT(0);}
-
   default async command bool SuperframeStructure.isBroadcastPending() { return FALSE;}
   default async event void BroadcastTx.transmitNowDone(ieee154_txframe_t *frame, ieee154_status_t status) {}
   default event message_t* FrameExtracted.received[uint8_t client](message_t* msg, ieee154_txframe_t *txFrame) {return msg;}
index f579f71f5b4d7fd0070ddab478441c5824244e64..8415c1ba813e5b39599baee271516852fb91aaa1 100644 (file)
@@ -97,7 +97,7 @@ implementation
   norace bool m_resume;
   norace ieee154_txframe_t *m_currentFrame;
   norace ieee154_txframe_t *m_lastFrame;
-  norace ieee154_macRxOnWhenIdle_t macRxOnWhenIdle;
+  norace ieee154_macRxOnWhenIdle_t m_macRxOnWhenIdle;
 
   /* variables for the unslotted CSMA-CA */
   norace ieee154_csma_t m_csma;
@@ -108,10 +108,9 @@ implementation
   norace ieee154_status_t m_txStatus;
   norace uint32_t m_transactionTime;
   norace bool m_indirectTxPending = FALSE;
-  norace ieee154_macMaxFrameTotalWaitTime_t m_macMaxFrameTotalWaitTime;
 
   /* function / task prototypes */
-  next_state_t tryReceive(bool startIndirectTxTimer);
+  next_state_t tryReceive();
   next_state_t tryTransmit();
   next_state_t trySwitchOff();
   void backupCurrentFrame();
@@ -227,7 +226,6 @@ implementation
     //  m_transactionTime += call MLME_GET.macMinLIFSPeriod(); 
     // else 
     //  m_transactionTime += call MLME_GET.macMinSIFSPeriod(); 
-    m_macMaxFrameTotalWaitTime = call MLME_GET.macMaxFrameTotalWaitTime();
     m_currentFrame = frame;
   }
 
@@ -256,7 +254,7 @@ implementation
       // Check 1: was an indirect transmission successfully started 
       // and are we now waiting for a frame from the coordinator?
       if (m_indirectTxPending) {
-        next = tryReceive(TRUE);
+        next = tryReceive();
       }
 
       // Check 2: is some other operation (like MLME-SCAN or MLME-RESET) pending? 
@@ -277,8 +275,8 @@ implementation
       }
 
       // Check 4: should we be in receive mode?
-      else if (call IsRxEnableActive.getNow() || macRxOnWhenIdle) {
-        next = tryReceive(FALSE);
+      else if (call IsRxEnableActive.getNow() || m_macRxOnWhenIdle) {
+        next = tryReceive();
         if (next == DO_NOTHING) {
           // if there was an active MLME_RX_ENABLE.request then we'll
           // inform the next higher layer that radio is now in Rx mode
@@ -329,7 +327,7 @@ implementation
     return next;
   }
 
-  next_state_t tryReceive(bool startIndirectTxTimer)
+  next_state_t tryReceive()
   {
     next_state_t next;
     if (call RadioRx.isReceiving())
@@ -338,8 +336,6 @@ implementation
       next = SWITCH_OFF;
     else {
       call RadioRx.enableRx(0, 0);
-      if (startIndirectTxTimer)
-        post startIndirectTxTimerTask();
       next = WAIT_FOR_RXDONE;
     }
     return next;
@@ -355,16 +351,31 @@ implementation
     return next;
   }
 
-  async event void RadioOff.offDone() { m_lock = FALSE; updateState();}
-  async event void RadioRx.enableRxDone() { m_lock = FALSE; updateState();}
-  event void RxEnableStateChange.notify(bool whatever) { 
+  async event void RadioOff.offDone() 
+  { 
+    m_lock = FALSE; 
+    updateState();
+  }
+
+  async event void RadioRx.enableRxDone() 
+  { 
+    if (m_indirectTxPending) // indirect transmission, now waiting for data
+      post startIndirectTxTimerTask();
+    m_lock = FALSE; 
+    updateState();
+  }
+
+  event void RxEnableStateChange.notify(bool whatever) 
+  { 
     if (!call RadioToken.isOwner())
       call RadioToken.request();
     else
       updateState();
   }
-  event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) {
-    atomic macRxOnWhenIdle = *((ieee154_macRxOnWhenIdle_t*) val);
+
+  event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) 
+  {
+    atomic m_macRxOnWhenIdle = *((ieee154_macRxOnWhenIdle_t*) val);
     signal RxEnableStateChange.notify(TRUE);
   }
 
@@ -380,7 +391,7 @@ implementation
 
   task void startIndirectTxTimerTask()
   {
-    call IndirectTxWaitTimer.startOneShot(m_macMaxFrameTotalWaitTime); 
+    call IndirectTxWaitTimer.startOneShot(call MLME_GET.macMaxFrameTotalWaitTime()); 
   }
 
   async event void UnslottedCsmaCa.transmitDone(ieee154_txframe_t *frame, 
index 62633314eddb54117aec362f8c9f0936364b1a54..26a24c7d3e08c7f65ba2506b7d2d0c8bfea5a6a9 100644 (file)
@@ -95,7 +95,6 @@ configuration TKN154BeaconEnabledP
     interface Alarm<TSymbolIEEE802154,uint32_t> as Alarm9;
     interface Alarm<TSymbolIEEE802154,uint32_t> as Alarm10;
     interface Alarm<TSymbolIEEE802154,uint32_t> as Alarm11;
-    interface Alarm<TSymbolIEEE802154,uint32_t> as Alarm12;
 
     interface Timer<TSymbolIEEE802154> as Timer1;
     interface Timer<TSymbolIEEE802154> as Timer2;
@@ -402,8 +401,7 @@ implementation
   PibP.DispatchReset -> DeviceCap;
   DeviceCap.CapEndAlarm = Alarm3;
   DeviceCap.BLEAlarm = Alarm4;
-  DeviceCap.IndirectTxWaitAlarm = Alarm5;
-  DeviceCap.BroadcastAlarm = Alarm6;
+  DeviceCap.RxWaitAlarm = Alarm5;
   DeviceCap.RadioToken -> DeviceCapRadioClient;
   DeviceCap.SuperframeStructure -> BeaconSynchronizeP.IncomingSF;
   DeviceCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
@@ -429,8 +427,8 @@ implementation
   components new RadioClientC(RADIO_CLIENT_COORDCAP) as CoordCapRadioClient, 
              new BackupP(ieee154_cap_frame_backup_t);
   PibP.DispatchReset -> CoordCap;
-  CoordCap.CapEndAlarm = Alarm7;
-  CoordCap.BLEAlarm = Alarm8;
+  CoordCap.CapEndAlarm = Alarm6;
+  CoordCap.BLEAlarm = Alarm7;
   CoordCap.RadioToken -> CoordCapRadioClient;
   CoordCap.SuperframeStructure -> BeaconTransmitP.OutgoingSF;
   CoordCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
@@ -458,8 +456,8 @@ implementation
   PibP.MacReset -> DeviceCfp;
   DeviceCfp.RadioToken -> DeviceCfpRadioClient;
   DeviceCfp.IncomingSF -> BeaconSynchronizeP.IncomingSF; 
-  DeviceCfp.CfpSlotAlarm = Alarm9;
-  DeviceCfp.CfpEndAlarm = Alarm10;
+  DeviceCfp.CfpSlotAlarm = Alarm8;
+  DeviceCfp.CfpEndAlarm = Alarm9;
   DeviceCfp.RadioTx -> DeviceCfpRadioClient;
   DeviceCfp.RadioRx -> DeviceCfpRadioClient;
   DeviceCfp.RadioOff -> DeviceCfpRadioClient;
@@ -472,8 +470,8 @@ implementation
   PibP.MacReset -> CoordCfp;
   CoordCfp.RadioToken -> CoordCfpRadioClient;
   CoordCfp.OutgoingSF -> BeaconTransmitP.OutgoingSF; 
-  CoordCfp.CfpSlotAlarm = Alarm11;
-  CoordCfp.CfpEndAlarm = Alarm12;
+  CoordCfp.CfpSlotAlarm = Alarm10;
+  CoordCfp.CfpEndAlarm = Alarm11;
   CoordCfp.RadioTx -> CoordCfpRadioClient;
   CoordCfp.RadioRx -> CoordCfpRadioClient;
   CoordCfp.RadioOff -> CoordCfpRadioClient;