]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Fixed a bug with the resource transfer
authorjanhauer <janhauer>
Thu, 23 Oct 2008 16:09:28 +0000 (16:09 +0000)
committerjanhauer <janhauer>
Thu, 23 Oct 2008 16:09:28 +0000 (16:09 +0000)
16 files changed:
tos/lib/mac/tkn154/BeaconSynchronizeP.nc
tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/CsmaP.nc
tos/lib/mac/tkn154/PibP.nc
tos/lib/mac/tkn154/RxEnableP.nc
tos/lib/mac/tkn154/SimpleTransferArbiterP.nc
tos/lib/mac/tkn154/TKN154P.nc
tos/lib/mac/tkn154/TKN154_DEBUG.h
tos/lib/mac/tkn154/dummies/NoBeaconSynchronizeP.nc
tos/lib/mac/tkn154/dummies/NoBeaconTransmitP.nc
tos/lib/mac/tkn154/dummies/NoCoordCfpP.nc
tos/lib/mac/tkn154/dummies/NoCsmaP.nc
tos/lib/mac/tkn154/dummies/NoDeviceCfpP.nc
tos/lib/mac/tkn154/dummies/NoRxEnableP.nc
tos/lib/mac/tkn154/interfaces/private/ResourceTransferControl.nc
tos/lib/mac/tkn154/interfaces/private/ResourceTransferred.nc

index db92fd9b5e2d6d5648c144e1a742b2c33bd3c502..c4c570c527cd2b881ff942fa268d692dc933549d 100644 (file)
@@ -71,10 +71,11 @@ module BeaconSynchronizeP
     interface Alarm<TSymbolIEEE802154,uint32_t> as TrackAlarm;
     interface RadioRx as BeaconRx;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface DataRequest;
     interface FrameRx as CoordRealignmentRx;
     interface Resource as Token;
+    interface GetNow<bool> as IsTokenRequested;
     interface ResourceTransferred as TokenTransferred;
     interface ResourceTransfer as TokenToCap;
     interface TimeCalc;
@@ -157,7 +158,7 @@ implementation
 
     currentChannelBit <<= logicalChannel;
     if (!(currentChannelBit & supportedChannels) || (call MLME_GET.macPANId() == 0xFFFF) ||
-        (channelPage != IEEE154_SUPPORTED_CHANNELPAGE) || !call IsBeaconEnabledPAN.get())
+        (channelPage != IEEE154_SUPPORTED_CHANNELPAGE) || !call IsBeaconEnabledPAN.getNow())
       return IEEE154_INVALID_PARAMETER;
 
     call Debug.log(LEVEL_INFO,SyncP_REQUEST, logicalChannel, channelPage, trackBeacon);
@@ -171,7 +172,12 @@ implementation
       m_internalRequest = FALSE;
       m_updatePending = TRUE;
       call Debug.log(LEVEL_INFO,SyncP_RESOURCE_REQUEST, 0, 0, 0);
-      call Token.request();
+      atomic {
+        // if we are tracking then we'll get the Token automatically,
+        // otherwise request it now
+        if (!m_tracking && !call Token.isOwner())
+          call Token.request();  
+      }
     }
     call Debug.flush();
     return IEEE154_SUCCESS;
@@ -191,7 +197,6 @@ implementation
 
   event void Token.granted()
   {
-    call Debug.flush();
     call Debug.log(LEVEL_INFO,SyncP_GOT_RESOURCE, m_lastBeaconRxTime+m_beaconInterval, 
         m_beaconInterval, (m_updatePending<<1)+m_tracking);
     if (m_updatePending){
@@ -209,6 +214,7 @@ implementation
           call MLME_GET.macPANId(), m_updateLogicalChannel);
     }
     getNextBeacon();
+    call Debug.flush();
   }
 
   void getNextBeacon()
@@ -218,11 +224,12 @@ implementation
       // we have received at least one previous beacon
       m_state = S_PREPARE;
       if (!m_tracking){
+        // nothing to do, just give up the token
         call Debug.log(LEVEL_INFO,SyncP_RELEASE_RESOURCE, 0, 0, 0);
         call Token.release();
         return;
       }
-      while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon
+      while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon!
         missed = TRUE;
         call Debug.log(LEVEL_INFO,SyncP_BEACON_MISSED_1, m_lastBeaconRxTime, m_dt, missed);
         m_dt += m_beaconInterval;
@@ -247,7 +254,12 @@ implementation
 
   async event void TokenTransferred.transferred()
   {
-    if (m_updatePending)
+    if (call IsTokenRequested.getNow()){
+      // some other component needs the token - we give it up for now,  
+      // but make another request to get it back later
+      call Token.request();
+      call Token.release();
+    } else if (m_updatePending)
       post signalGrantedTask();
     else
       getNextBeacon();
@@ -327,10 +339,10 @@ implementation
 
   task void processBeaconTask()
   {
-
     // valid beacon timestamp is pre-condition for slotted CSMA-CA
     if (m_beaconSwapBufferReady || !call Frame.isTimestampValid(m_beaconBufferPtr)){
       // missed a beacon!
+      m_sfSlotDuration = 0; // CAP len will be 0
       m_numBeaconsLost++;
       m_dt += m_beaconInterval;
       call Debug.log(LEVEL_IMPORTANT, SyncP_BEACON_MISSED_3,m_numBeaconsLost,0,m_lastBeaconRxTime);
@@ -392,11 +404,12 @@ implementation
       if (m_stopTracking){
         m_tracking = FALSE;
         call Debug.log(LEVEL_INFO,SyncP_RELEASE_RESOURCE, 0, 0, 0);
+        if (m_updatePending) // there is already a new request pending...
+          call Token.request();
         call Token.release();
       } else {
-        error_t req = call Token.request();
-        call Debug.log(LEVEL_INFO,SyncP_TRANSFER_RESOURCE, req, 0, 0);
-        call TokenToCap.transfer(); 
+        call Debug.log(LEVEL_INFO,SyncP_TRANSFER_RESOURCE, 0, 0, 0);
+        call TokenToCap.transfer(); // borrow Token to CAP/CFP module, we'll get it back afterwards
       }
       
       if (pendAddrSpec & PENDING_ADDRESS_SHORT_MASK)
index c7b88333a50d14396a83d60eef2366d170296985..b3b04dbd3560d0d409f30aef71bfc407c83db775 100644 (file)
@@ -65,13 +65,14 @@ module BeaconTransmitP
     interface Alarm<TSymbolIEEE802154,uint32_t> as BeaconTxAlarm;
     interface Timer<TSymbolIEEE802154> as BeaconPayloadUpdateTimer;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface RadioTx as BeaconTx;
     interface MLME_GET;
     interface MLME_SET;
     interface Resource as Token;
     interface ResourceTransferred as TokenTransferred;
     interface ResourceTransfer as TokenToBroadcast;
+    interface GetNow<bool> as IsTokenRequested;
     interface FrameTx as RealignmentBeaconEnabledTx;
     interface FrameTx as RealignmentNonBeaconEnabledTx;
     interface FrameRx as BeaconRequestRx;
@@ -229,8 +230,8 @@ implementation
       status = IEEE154_INVALID_PARAMETER;
     else if (m_requests & (REQUEST_CONFIRM_PENDING | REQUEST_UPDATE_SF))
       status = IEEE154_TRANSACTION_OVERFLOW;
-    else if ((call IsBeaconEnabledPAN.get() && beaconOrder > 14) ||
-              (!call IsBeaconEnabledPAN.get() && beaconOrder < 15))
+    else if ((call IsBeaconEnabledPAN.getNow() && beaconOrder == 15) ||
+              (!call IsBeaconEnabledPAN.getNow() && beaconOrder < 15))
       status = IEEE154_INVALID_PARAMETER;
     else {
       // new configuration *will* be put in operation
@@ -253,7 +254,7 @@ implementation
       if (coordRealignment)
         m_requests |= REQUEST_REALIGNMENT;
       if (m_beaconOrder == 15) // only request token if we're not already transmitting beacons
-        call Token.request(); 
+        call Token.request();  // otherwise we'll get it eventually and update the superframe then
     }
     return status;
   }
@@ -413,7 +414,13 @@ implementation
 
   async event void TokenTransferred.transferred()
   {
-    post grantedTask();
+    if (call IsTokenRequested.getNow()){
+      // some other component needs the token - we give it up for now,  
+      // but make another request to get it back later
+      call Token.request();
+      call Token.release();
+    } else
+      post grantedTask();
   }  
 
   async event void RadioOff.offDone()
@@ -428,7 +435,7 @@ implementation
       post grantedTask();
       call Debug.log(LEVEL_CRITICAL, StartP_OWNER_TOO_FAST, 0, 0, 0);
       return;
-    } else if (m_beaconOrder > 14){
+    } else if (m_beaconOrder == 15){
       call Token.release();
     } else {
       atomic {
@@ -535,8 +542,7 @@ implementation
       m_BLELen += m_battLifeExtPeriods;
     } else
       m_BLELen = 0;
-    call Token.request();             // register another request, before ...
-    call TokenToBroadcast.transfer(); // ... we let Broadcast module take over
+    call TokenToBroadcast.transfer(); // borrow Token to Broadcast/CAP/CFP module, we'll get it back afterwards
     post txDoneTask();
   }
 
index 18354816aa39060dbac0fd508b389d932bd16198..4567accfe79db8303447325b46bbbe1d5bf1d253 100644 (file)
@@ -72,10 +72,9 @@ generic module CsmaP(uint8_t superframeDirection)
     interface Alarm<TSymbolIEEE802154,uint32_t> as IndirectTxWaitAlarm;
     interface Alarm<TSymbolIEEE802154,uint32_t> as BroadcastAlarm;
     interface Resource as Token;
+    interface GetNow<bool> as IsTokenRequested;
     interface ResourceTransfer as TokenToCfp;
     interface ResourceTransferred as TokenTransferred;
-    interface ResourceRequested as TokenRequested;
-    interface GetNow<bool> as IsTokenRequested;
     interface GetNow<uint32_t> as CapStart; 
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
     interface GetNow<uint32_t> as CapLen; 
@@ -89,7 +88,7 @@ generic module CsmaP(uint8_t superframeDirection)
     interface RadioTx;
     interface RadioRx;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface MLME_GET;
     interface MLME_SET;
     interface Ieee802154Debug as Debug;
@@ -138,7 +137,6 @@ implementation
   norace bool m_indirectTxPending = FALSE;
   norace bool m_broadcastRxPending;
   norace ieee154_macMaxFrameTotalWaitTime_t m_macMaxFrameTotalWaitTime;
-  norace bool m_isBeaconEnabledPAN;
 
   uint16_t generateRandomBackoff(uint8_t BE);
   void stopAllAlarms();
@@ -156,10 +154,6 @@ implementation
 
   command error_t Reset.init()
   {
-    if (call Token.isOwner()){
-      call Leds.led0On(); // internal error
-      return FAIL;
-    }
     if (m_currentFrame)
       signal FrameTx.transmitDone(m_currentFrame, IEEE154_TRANSACTION_OVERFLOW);
     if (m_lastFrame)
@@ -167,8 +161,6 @@ implementation
     if (m_bcastFrame)
       signalTxBroadcastDone(m_bcastFrame, IEEE154_TRANSACTION_OVERFLOW);
     m_currentFrame = m_lastFrame = m_bcastFrame = NULL;
-    m_macMaxFrameTotalWaitTime = call MLME_GET.macMaxFrameTotalWaitTime();
-    m_isBeaconEnabledPAN = call IsBeaconEnabledPAN.get();
     stopAllAlarms();
     return SUCCESS;
   }
@@ -177,11 +169,18 @@ implementation
   {
     // we got the token, i.e. CAP has just started    
     uint32_t actualCapLen = call CapLen.getNow();
-    if (m_isBeaconEnabledPAN && (DEVICE_ROLE && !call IsTrackingBeacons.getNow())){
-      // rare case: we're on a beacon-enabled PAN, not tracking beacons, searched
-      // and didn't find a beacon for aBaseSuperframeDuration*(2n+1) symbols
+    if (!call IsBeaconEnabledPAN.getNow()){
+      call Leds.led0On(); // internal error! 
+      call TokenToCfp.transfer();
+      call Debug.log(LEVEL_IMPORTANT, CapP_INTERNAL_ERROR, 0,0,0);
+    } else if (DEVICE_ROLE && actualCapLen == 0){
+      // very rare case: 
+      // this can only happen, if we're on a beacon-enabled PAN, not tracking beacons, 
+      // and searched but didn't find a beacon for aBaseSuperframeDuration*(2n+1) symbols
       // -> transmit current frame using unslotted CSMA-CA
       m_numCCA = 1;
+      updateState();
+      return;
     } else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
       call Debug.log(LEVEL_IMPORTANT, CapP_TOO_SHORT, superframeDirection, actualCapLen, IEEE154_RADIO_GUARD_TIME);
       call TokenToCfp.transfer();
@@ -216,7 +215,7 @@ implementation
       return IEEE154_TRANSACTION_OVERFLOW;
     else {
       setCurrentFrame(frame);
-      if (!m_isBeaconEnabledPAN){
+      if (!call IsBeaconEnabledPAN.getNow()){
         call Token.request(); // prepare for unslotted CSMA-CA
       } else {
         // a beacon must be found before transmitting in a beacon-enabled PAN
@@ -270,7 +269,7 @@ implementation
     if (call MLME_GET.macBattLifeExt() && m_macMinBE > 2)
       m_macMinBE = 2;
     m_BE = m_macMinBE;
-    if (m_isBeaconEnabledPAN)
+    if (call IsBeaconEnabledPAN.getNow())
       m_numCCA = 2;
     else
       m_numCCA = 1;
@@ -337,7 +336,7 @@ implementation
       m_lock = TRUE; // lock
 
       // Check 1: for beacon-enabled PANs, has the CAP finished?
-      if (m_isBeaconEnabledPAN 
+      if (call IsBeaconEnabledPAN.getNow() 
           && (COORD_ROLE || call IsTrackingBeacons.getNow()) // FALSE only if device could't find a beacon
           && (call TimeCalc.hasExpired(call CapStart.getNow(), call CapLen.getNow()-IEEE154_RADIO_GUARD_TIME) ||
           !call CapEndAlarm.isRunning())){
@@ -375,11 +374,13 @@ implementation
       }
 
       // Check 4: is some other operation (like MLME-SCAN or MLME-RESET) pending? 
-      else if (call IsTokenRequested.getNow()) {
+      else if (call IsTokenRequested.getNow() && call IsBeaconEnabledPAN.getNow()) {
         if (call RadioOff.isOff()) {
-          stopAllAlarms();  // may still fire, locked through isOwner()
-          call Token.release();
-          next = DO_NOTHING;
+          stopAllAlarms();  // may still fire, but is locked through isOwner()
+          // nothing more to do... just release the Token
+          m_lock = FALSE; // unlock
+          call TokenToCfp.transfer();
+          return;
         } else 
           next = SWITCH_OFF;
       }
@@ -411,10 +412,12 @@ implementation
       // Check 8: just make sure the radio is switched off  
       else {
         next = trySwitchOff();
-        if (next == DO_NOTHING && (!m_isBeaconEnabledPAN || (DEVICE_ROLE && !call IsTrackingBeacons.getNow()))){
+        if (next == DO_NOTHING && 
+            (!call IsBeaconEnabledPAN.getNow() || (DEVICE_ROLE && call CapLen.getNow() == 0))){
           // nothing more to do... just release the Token
+          stopAllAlarms();  // may still fire, but is locked through isOwner()
           m_lock = FALSE; // unlock
-          call TokenToCfp.transfer();
+          call Token.release();
           return;
         }
       }
@@ -703,31 +706,10 @@ implementation
 
   event void Token.granted()
   {
-    // will not happen
-  }
-
-  task void tokenRequestedTask()
-  {
-    signal TokenRequested.requested();
-  }
-
-  async event void TokenRequested.requested() 
-  {
-    // TODO: this event can be generated by the BeaconTransmitP or
-    // BeaconSynchronizeP component - in this case the Token should
-    // probably not be released!
-    atomic {
-      if (call Token.isOwner()){
-        if (!m_lock && !(DEVICE_ROLE && m_indirectTxPending) && !(COORD_ROLE && m_bcastFrame))
-          call Token.release();
-        else
-          post tokenRequestedTask();
-      }
-    }
+    // the current frame should be transmitted using unslotted CSMA-CA
+    updateState();
   }
 
-  async event void TokenRequested.immediateRequested() {}
-
   default event void FrameTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status){}
   default event message_t* FrameRx.received[uint8_t client](message_t* data){return data;}
   default async command bool IsRxEnableActive.getNow(){return FALSE;}
index eb2f9bd0d2cbb7c780112b39dd658f33eb8e3dda..d8f1c286b604c9b91629ea3747697e948ce08d08 100644 (file)
@@ -50,7 +50,7 @@ module PibP {
     interface Set<ieee154_macBeaconTxTime_t> as SetMacBeaconTxTime;
     interface Set<ieee154_macPanCoordinator_t> as SetMacPanCoordinator;
     interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface FrameUtility;
     interface IEEE154Frame as Frame;
     interface IEEE154BeaconFrame as BeaconFrame;
@@ -77,7 +77,8 @@ implementation
   ieee154_PIB_t m_pib;
   uint8_t m_numResetClientPending;
   bool m_setDefaultPIB;
-  uint8_t m_panType;
+  norace uint8_t m_panType;
+  uint8_t m_updatePANType;
   uint8_t m_resetSpin;
 
 #ifdef IEEE154_EXTENDED_ADDRESS
@@ -176,7 +177,7 @@ implementation
     if (call PromiscuousModeGet.get())
       return IEEE154_TRANSACTION_OVERFLOW; // must first cancel promiscuous mode!
     m_setDefaultPIB = SetDefaultPIB;
-    m_panType = PANType; 
+    m_updatePANType = PANType; 
     if (!call Token.isOwner())
       call Token.request();
     return IEEE154_SUCCESS;
@@ -202,8 +203,9 @@ implementation
 
   event void RadioControl.stopDone(error_t error)
   {
-    call CapReset.init();       // resets the CAP component(s)
-    call CapQueueReset.init();  // resets the CAP queue component(s)
+    m_panType = m_updatePANType;
+    call CapReset.init();       // resets the CAP component(s), spool out frames
+    call CapQueueReset.init();  // resets the CAP queue component(s), spool out frames
     call MacReset.init();       // resets the remaining components
     m_resetSpin = 5;
     post resetSpinTask();
@@ -1047,7 +1049,7 @@ implementation
     return dest == m_pib.macCoordExtendedAddress;
   }
 
-  command bool IsBeaconEnabledPAN.get()
+  async command bool IsBeaconEnabledPAN.getNow()
   {
     return (m_panType == BEACON_ENABLED_PAN);
   }
index b7dad3a8573d3a32994d536369032bea9d5baaa9..100ddac1ee3822829958e1752a00e3c457b2a9f8 100644 (file)
@@ -48,7 +48,7 @@ module RxEnableP
   {
     interface Ieee802154Debug as Debug;
     interface Timer<TSymbolIEEE802154> as RxEnableTimer;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
     interface GetNow<bool> as IsTrackingBeacons;
     interface GetNow<uint32_t> as IncomingSfStart; 
@@ -95,7 +95,7 @@ implementation
       return IEEE154_TRANSACTION_OVERFLOW;
     if (RxOnTime > 0xFFFFFF || RxOnDuration > 0xFFFFFF)
       return IEEE154_INVALID_PARAMETER;
-    if (call IsBeaconEnabledPAN.get()){
+    if (call IsBeaconEnabledPAN.getNow()){
       if (call IsSendingBeacons.getNow() && call IsMacPanCoordinator.get()){
         // for OUTGOING SUPERFRAME
         lastBeaconTime = call OutgoingSfStart.getNow();
index 76ae05b4294bae3e70e44bd1d7c0784a50fbf22e..e1f8d68ab33de5a0e50562a9e9d204943f615a58 100644 (file)
@@ -68,17 +68,12 @@ implementation {
   uint8_t state = RES_IDLE;
   norace uint8_t resId = NO_RES;
   norace uint8_t reqResId;
-  norace uint8_t numTransfers;
-  norace bool reqWhileTransferred;
   
   task void grantedTask();
-  task void checkResourceRequestedTask();
   
   async command error_t Resource.request[uint8_t id]() {
     signal ResourceRequested.requested[resId]();
     atomic {
-      if (numTransfers > 0)
-        reqWhileTransferred = TRUE;
       if(state == RES_IDLE) {
         state = RES_GRANTING;
         reqResId = id;
@@ -106,8 +101,6 @@ implementation {
     bool released = FALSE;
     atomic {
       if(state == RES_BUSY && resId == id) {
-        numTransfers = 0;
-        reqWhileTransferred = FALSE;
         if(call Queue.isEmpty() == FALSE) {
           reqResId = call Queue.dequeue();
           state = RES_GRANTING;
@@ -129,34 +122,21 @@ implementation {
 
   async command bool IsResourceRequested.getNow()
   {
-    return reqWhileTransferred;
-  }
-
-  task void checkResourceRequestedTask()
-  {
-    if (numTransfers && reqWhileTransferred)
-      signal ResourceRequested.requested[resId]();
+    return !(call Queue.isEmpty());
   }
 
   async command error_t ResourceTransferControl.transfer(uint8_t fromClient, uint8_t toClient)
   {
     atomic {
       if (call ArbiterInfo.userId() == fromClient){
-        numTransfers += 1;
         call ResourceConfigure.unconfigure[fromClient]();
         call ResourceConfigure.configure[resId]();
         resId = toClient;
-        post checkResourceRequestedTask();
         return SUCCESS;
       }
-    } 
+    }
     return FAIL;
   }
-
-  async command error_t ResourceTransferControl.release(uint8_t client)
-  {
-    return call Resource.release[client]();
-  }
     
   /**
     Check if the Resource is currently in use
index 0f838375d0e23567143b0fe025d4ed0c48d66674..99d3c848d6f05e4bf3e853667215fe6b01393284 100644 (file)
@@ -255,6 +255,7 @@ implementation
   BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
   BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
   BeaconTransmitP.Token -> BeaconTxRadioClient;
+  BeaconTransmitP.IsTokenRequested -> BeaconTxRadioClient;
   BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
   BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
   BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
@@ -291,6 +292,7 @@ implementation
   BeaconSynchronizeP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
   BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_CLIENT];
   BeaconSynchronizeP.Token -> SyncRadioClient;
+  BeaconSynchronizeP.IsTokenRequested -> SyncRadioClient;
   BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
   BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
   BeaconSynchronizeP.TimeCalc -> PibP;
@@ -428,10 +430,9 @@ implementation
   DeviceCap.IndirectTxWaitAlarm = Alarm5;
   DeviceCap.BroadcastAlarm = Alarm6;
   DeviceCap.Token -> DeviceCapRadioClient;
+  DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
   DeviceCap.TokenToCfp -> DeviceCapRadioClient;
   DeviceCap.TokenTransferred -> DeviceCapRadioClient;
-  DeviceCap.TokenRequested -> DeviceCapRadioClient;
-  DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
   DeviceCap.CapStart -> BeaconSynchronizeP.CapStart;
   DeviceCap.CapStartRefTime -> BeaconSynchronizeP.CapStartRefTime;
   DeviceCap.CapLen -> BeaconSynchronizeP.CapLen;
@@ -464,7 +465,6 @@ implementation
   CoordCap.Token -> CoordCapRadioClient;
   CoordCap.TokenToCfp -> CoordCapRadioClient;
   CoordCap.TokenTransferred -> CoordCapRadioClient;
-  CoordCap.TokenRequested -> CoordCapRadioClient;
   CoordCap.IsTokenRequested -> CoordCapRadioClient;
   CoordCap.CapStart -> BeaconTransmitP.CapStart;
   CoordCap.CapStartRefTime -> BeaconTransmitP.CapStartRefTime;
@@ -492,7 +492,6 @@ implementation
 
   components new RadioClientC() as DeviceCfpRadioClient;
   PibP.MacReset -> DeviceCfp;
-  DeviceCfp.Token -> DeviceCfpRadioClient;
   DeviceCfp.TokenTransferred -> DeviceCfpRadioClient;
   DeviceCfp.TokenRequested -> DeviceCfpRadioClient;
   DeviceCfp.TokenToBeaconSync -> DeviceCfpRadioClient;
@@ -515,9 +514,9 @@ implementation
 
   components new RadioClientC() as CoordCfpRadioClient;
   PibP.MacReset -> CoordCfp;
-  CoordCfp.Token -> CoordCfpRadioClient;
   CoordCfp.TokenTransferred -> CoordCfpRadioClient;
   CoordCfp.TokenRequested -> CoordCfpRadioClient;
+  CoordCfp.IsTokenRequested -> CoordCfpRadioClient;
   CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
   CoordCfp.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
   CoordCfp.CfpEnd -> BeaconTransmitP.CfpEnd; 
index 117ededfed345e0d5d1e926a35d711b6c6d8fdec..8169f913029abb5509b2f982a05c99fcf378907e 100644 (file)
 #define CapP_TOO_SHORT           0
 #define CapP_SET_CAP_END         1
 #define CapP_CAP_END_FIRED       2
+#define CapP_INTERNAL_ERROR      3
 
 #define DeviceCapTransmitP_CONTINUE           0
 #define DeviceCapTransmitP_TOVERFLOW          1
index be14b1bc6f8a5907a4ba2c55239c48da1132affa..5d49ff360d423d69574401bd2459f46a5c63de67 100644 (file)
@@ -71,10 +71,11 @@ module NoBeaconSynchronizeP
     interface Alarm<TSymbolIEEE802154,uint32_t> as TrackAlarm;
     interface RadioRx as BeaconRx;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface DataRequest;
     interface FrameRx as CoordRealignmentRx;
     interface Resource as Token;
+    interface GetNow<bool> as IsTokenRequested;
     interface ResourceTransfer as TokenToCap;
     interface ResourceTransferred as TokenTransferred;
     interface GetNow<bool> as IsSendingBeacons;
index 16c443e9db2c143a971372757da130170686ff34..9d6a059f694f1e8ca77472e1faafd6c3d4627e54 100644 (file)
@@ -65,11 +65,12 @@ module NoBeaconTransmitP
     interface Alarm<TSymbolIEEE802154,uint32_t> as BeaconTxAlarm;
     interface Timer<TSymbolIEEE802154> as BeaconPayloadUpdateTimer;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface RadioTx as BeaconTx;
     interface MLME_GET;
     interface MLME_SET;
     interface Resource as Token;
+    interface GetNow<bool> as IsTokenRequested;
     interface ResourceTransfer as TokenToBroadcast;
     interface ResourceTransferred as TokenTransferred;
     interface FrameTx as RealignmentBeaconEnabledTx;
index e142bf62f94b6390fe39e820787fe741c927c052..76974d2d9e2bf492a1072471b48ef8b7423d9a59 100644 (file)
@@ -52,10 +52,10 @@ module NoCoordCfpP
     interface FrameTx as CfpTx;
     interface Purge;
   } uses {
-    interface Resource as Token;
     interface ResourceTransferred as TokenTransferred;
-    interface ResourceRequested as TokenRequested;
     interface ResourceTransfer as TokenToBeaconTransmit;
+    interface ResourceRequested as TokenRequested;
+    interface GetNow<bool> as IsTokenRequested;
     interface GetNow<bool> as IsTrackingBeacons; 
     interface GetNow<uint32_t> as CfpEnd; 
     interface GetNow<ieee154_reftime_t*> as CapStartRefTime; 
@@ -94,13 +94,11 @@ implementation
   async event void TokenTransferred.transferred()
   {
     // the CFP has started, this component now owns the token -  
-    // because GTS is not implemented we release the token
-    // (or pass it back to BeaconTransmitP if 
-    // we are not tracking beacons)
-    if (call IsTrackingBeacons.getNow())
-      call Token.release();  
-    else
-      call TokenToBeaconTransmit.transfer();
+    // because GTS is not implemented we pass it back to the
+    // BeaconTransmitP component
+    // Note: this component must not use the Resource
+    // interface to release the token!
+    call TokenToBeaconTransmit.transfer();
   }
 
   async event void CfpEndAlarm.fired() {}
@@ -134,10 +132,10 @@ implementation
 
   async event void TokenRequested.requested()
   {
-    // someone (e.g. SCAN component) requested access to the radio,
-    // you might want to release the token...
+    // someone (e.g. SCAN component) requested access to the radio, we 
+    // should pass the token back to BeaconTransmitP, which can release it
+    // call TokenToBeaconTransmit.transfer();
   }
 
   async event void TokenRequested.immediateRequested(){ }
-  event void Token.granted(){ }
 }
index 790fb7e231a3683452d1f30c9a9165433cc8fa6c..7137064c8226b27a480f41fc7c3391d5179b4c82 100644 (file)
@@ -73,7 +73,7 @@ generic module NoCsmaP()
     interface RadioTx;
     interface RadioRx;
     interface RadioOff;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface MLME_GET;
     interface MLME_SET;
     interface Ieee802154Debug as Debug;
index 0d672ce6bc0ac8c5b63f6e847811c70073e41297..0cda4b605558976d5cba939732fe8857f33fd976 100644 (file)
@@ -51,7 +51,6 @@ module NoDeviceCfpP
     interface FrameTx as CfpTx;
     interface Purge;
   } uses {
-    interface Resource as Token;
     interface ResourceTransferred as TokenTransferred;
     interface ResourceRequested as TokenRequested;
     interface ResourceTransfer as TokenToBeaconSync;
@@ -92,14 +91,12 @@ implementation
 
   async event void TokenTransferred.transferred()
   { 
-    // the CFP has started, this component now owns the token. 
-    // because GTS is not implemented we release the token
-    // (or pass it back to BeaconSynchronizeP if 
-    // we are not transmitting beacons)
-    if (call IsSendingBeacons.getNow())
-      call Token.release();  
-    else
-      call TokenToBeaconSync.transfer();
+    // the CFP has started, this component now owns the token -  
+    // because GTS is not implemented we pass it back to the
+    // BeaconTransmitP component
+    // Note: this component must not use the Resource
+    // interface to release the token!
+    call TokenToBeaconSync.transfer();
   }
 
   async event void CfpEndAlarm.fired() {}
@@ -117,10 +114,10 @@ implementation
 
   async event void TokenRequested.requested()
   {
-    // someone requested access to the radio, you might
-    // consider releasing it...
+    // someone (e.g. SCAN component) requested access to the radio, we 
+    // should pass the token back to BeaconSynchronizeP, which can release it
+    // call TokenToBeaconSync.transfer();
   }
 
   async event void TokenRequested.immediateRequested(){ }
-  event void Token.granted(){ }
 }
index 97ad43b8c15fd0b0ff16a074d0d0fa3aa587cc56..63d76d82744cf835933fe5c13f76dd1d72fb74e0 100644 (file)
@@ -48,7 +48,7 @@ module NoRxEnableP
   {
     interface Ieee802154Debug as Debug;
     interface Timer<TSymbolIEEE802154> as RxEnableTimer;
-    interface Get<bool> as IsBeaconEnabledPAN;
+    interface GetNow<bool> as IsBeaconEnabledPAN;
     interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
     interface GetNow<bool> as IsTrackingBeacons;
     interface GetNow<uint32_t> as IncomingSfStart; 
index 06013582459abefa37888e8834f23f578ea4b45f..a7a82ea43b8e91f30cec17540735893942fb68b7 100644 (file)
@@ -34,5 +34,4 @@
 interface ResourceTransferControl 
 {
   async command error_t transfer(uint8_t fromClient, uint8_t toClient);
-  async command error_t release(uint8_t client);
 }
index 1e9ccd7f74e9e7c029ce1c60bf8653fda3565913..48f365071920339df9ff73de7bd4c60200de047f 100644 (file)
@@ -37,8 +37,7 @@ interface ResourceTransferred
   /** 
    * Ownership of a resource is transferred, possibly overriding the default
    * queueing policy. This event is similar to an async Resource.granted()
-   * event, but when a the resource is released, it is released on behalf of
-   * the client who was last signalled the Resource.granted() event.
+   * event, initiated by the previous owner of the resource.
    *
    * @see ResourceTransfer interface
    */