]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
1) simplified the resource transfer: removed ResourceTransfer* interfaces and corresp...
authorjanhauer <janhauer>
Tue, 24 Mar 2009 12:56:46 +0000 (12:56 +0000)
committerjanhauer <janhauer>
Tue, 24 Mar 2009 12:56:46 +0000 (12:56 +0000)
2) made some small fixes/modifications to facilitate porting to micaz, as proposed by Daniel F. PiƱeiro Santos

32 files changed:
tos/chips/cc2420_tkn154/CC2420ControlP.nc
tos/lib/mac/tkn154/BeaconSynchronizeP.nc
tos/lib/mac/tkn154/BeaconTransmitP.nc
tos/lib/mac/tkn154/CoordBroadcastP.nc
tos/lib/mac/tkn154/DataP.nc
tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc
tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc
tos/lib/mac/tkn154/PibP.nc
tos/lib/mac/tkn154/PromiscuousModeP.nc
tos/lib/mac/tkn154/RadioClientC.nc
tos/lib/mac/tkn154/RadioControlP.nc
tos/lib/mac/tkn154/ScanP.nc
tos/lib/mac/tkn154/SimpleRoundRobinTransferArbiterC.nc [deleted file]
tos/lib/mac/tkn154/SimpleTransferArbiterP.nc
tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc
tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc
tos/lib/mac/tkn154/TKN154_MAC.h
tos/lib/mac/tkn154/TransferClientP.nc [deleted file]
tos/lib/mac/tkn154/dummies/NoBeaconSynchronizeP.nc
tos/lib/mac/tkn154/dummies/NoBeaconTransmitP.nc
tos/lib/mac/tkn154/dummies/NoCoordBroadcastP.nc
tos/lib/mac/tkn154/dummies/NoCoordCfpP.nc
tos/lib/mac/tkn154/dummies/NoDeviceCfpP.nc
tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc
tos/lib/mac/tkn154/dummies/NoPromiscuousModeP.nc
tos/lib/mac/tkn154/dummies/NoScanP.nc
tos/lib/mac/tkn154/interfaces/private/ResourceTransfer.nc [deleted file]
tos/lib/mac/tkn154/interfaces/private/ResourceTransferConnector.nc [deleted file]
tos/lib/mac/tkn154/interfaces/private/ResourceTransferControl.nc [deleted file]
tos/lib/mac/tkn154/interfaces/private/ResourceTransferred.nc [deleted file]
tos/lib/mac/tkn154/interfaces/private/TransferableResource.nc [new file with mode: 0644]
tos/platforms/telosb/mac/tkn154/platform_message.h

index 12315c7a0b37bf5372eb03f3270292a1716b40cb..ab122287c84617a4ff6af81fa6851c16e30a2ece 100644 (file)
@@ -447,10 +447,6 @@ implementation {
   /***************** StartupAlarm Events ****************/
   async event void StartupAlarm.fired() {
     if ( m_state == S_VREG_STARTING ) {
-      cc2420_status_t status;
-      do {
-       status = call SNOP.strobe();  
-      } while (!(status & CC2420_STATUS_XOSC16M_STABLE));
       m_state = S_VREG_STARTED;
       call RSTN.clr();
       call RSTN.set();
index 87412974b2455f949e18ea78d91804cc64714a96..779a81f41bcf3904ecae0948378fcb95f3266363 100644 (file)
@@ -63,10 +63,7 @@ module BeaconSynchronizeP
     interface RadioOff;
     interface DataRequest;
     interface FrameRx as CoordRealignmentRx;
-    interface Resource as Token;
-    interface GetNow<bool> as IsTokenRequested;
-    interface ResourceTransferred as TokenTransferred;
-    interface ResourceTransfer as TokenToCap;
+    interface TransferableResource as RadioToken;
     interface TimeCalc;
     interface IEEE154Frame as Frame;
     interface Leds;
@@ -160,10 +157,10 @@ implementation
         m_updateTrackBeacon = trackBeacon;
         m_updatePending = TRUE;
         atomic {
-          // if we are tracking then we'll get the Token automatically,
+          // if we are tracking then we'll get the RadioToken automatically,
           // otherwise request it now
-          if (!m_tracking && !call Token.isOwner())
-            call Token.request();  
+          if (!m_tracking && !call RadioToken.isOwner())
+            call RadioToken.request();  
         }
       }
     }
@@ -171,7 +168,7 @@ implementation
     return status;
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     dbg_serial("BeaconSynchronizeP","Got token, expecting beacon in %lu\n",
         (uint32_t) ((m_lastBeaconRxTime + m_dt) - call TrackAlarm.getNow())); 
@@ -191,17 +188,11 @@ implementation
     trackNextBeacon();
   }
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t clientFrom)
   {
     dbg_serial("BeaconSynchronizeP","Token.transferred(), expecting beacon in %lu symbols.\n",
         (uint32_t) ((m_lastBeaconRxTime + m_dt) - call TrackAlarm.getNow())); 
-    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
-      dbg_serial("BeaconSynchronizeP", "Token is requested, releasing it now.\n");
-      call Token.request();
-      call Token.release();
-    } else if (m_updatePending)
+    if (m_updatePending)
       post signalGrantedTask();
     else
       trackNextBeacon();
@@ -210,7 +201,7 @@ implementation
 
   task void signalGrantedTask()
   {
-    signal Token.granted();
+    signal RadioToken.granted();
   }
 
   void trackNextBeacon()
@@ -218,14 +209,16 @@ implementation
     bool missed = FALSE;
 
     if (m_state != S_INITIAL_SCAN) {
-      // we have received at least one previous beacon
-      m_state = S_PREPARE;
+
       if (!m_tracking) {
         // nothing to do, just give up the token
         dbg_serial("BeaconSynchronizeP", "Stop tracking.\n");
-        call Token.release();
+        call RadioToken.release();
         return;
       }
+
+      // we have received at least one previous beacon
+      m_state = S_PREPARE;
       while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)) { // missed a beacon!
         dbg_serial("BeaconSynchronizeP", "Missed a beacon, expected it: %lu, now: %lu\n", 
             m_lastBeaconRxTime + m_dt, call TrackAlarm.getNow());
@@ -233,19 +226,22 @@ implementation
         m_dt += m_beaconInterval;
         m_numBeaconsLost++;
       }
+
       if (m_numBeaconsLost >= IEEE154_aMaxLostBeacons) {
         dbg_serial("BeaconSynchronizeP", "Missed too many beacons.\n");
         post processBeaconTask();
         return;
       }
+
       if (missed) {
         // let other components get a chance to use the radio
-        call Token.request();
+        call RadioToken.request();
         dbg_serial("BeaconSynchronizeP", "Allowing other components to get the token.\n");
-        call Token.release();
+        call RadioToken.release();
         return;
       }
     }
+
     if (call RadioOff.isOff())
       signal RadioOff.offDone();
     else
@@ -350,9 +346,9 @@ implementation
               call MLME_GET.phyCurrentPage(), 
               NULL);
       } else
-        call Token.request(); // make another request again (before giving the token up)
+        call RadioToken.request(); // make another request again (before giving the token up)
 
-      call Token.release();
+      call RadioToken.release();
     } else { 
       // got the beacon!
       uint8_t *payload = (uint8_t *) m_beaconPtr->data;
@@ -398,11 +394,14 @@ implementation
         m_tracking = FALSE;
         dbg_serial("BeaconSynchronizeP", "Stop tracking.\n");
         if (m_updatePending) // there is already a new request ...
-          call Token.request();
-        call Token.release();
+          call RadioToken.request();
+        call RadioToken.release();
       } else {
         dbg_serial("BeaconSynchronizeP", "Handing over to CAP.\n");
-        call TokenToCap.transfer(); 
+        // we pass on the token now, but make a reservation to get it back 
+        // to receive the next beacon (at the start of the next superframe)
+        call RadioToken.request();  
+        call RadioToken.transferTo(RADIO_CLIENT_DEVICECAP); 
       }
       
       if (pendAddrSpec & PENDING_ADDRESS_SHORT_MASK)
@@ -442,13 +441,13 @@ implementation
   command error_t TrackSingleBeacon.start()
   {
     // Track a single beacon now
-    if (!m_tracking && !m_updatePending && !call Token.isOwner()) {
+    if (!m_tracking && !m_updatePending && !call RadioToken.isOwner()) {
       // find a single beacon now (treat this like a user request)
       m_updateLogicalChannel = call MLME_GET.phyCurrentChannel();
       m_updateTrackBeacon = FALSE;
       m_stopTracking = TRUE;
       m_updatePending = TRUE;
-      call Token.request();
+      call RadioToken.request();
     }
     return SUCCESS;
   }
index 8d977ae71d4d44be05d5f060b3d2347b64a4b098..63bdedbc524366ffeb69976c44f7f9f14023a45b 100644 (file)
@@ -59,10 +59,7 @@ module BeaconTransmitP
     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 TransferableResource as RadioToken;
     interface FrameTx as RealignmentBeaconEnabledTx;
     interface FrameTx as RealignmentNonBeaconEnabledTx;
     interface FrameRx as BeaconRequestRx;
@@ -154,7 +151,8 @@ implementation
   /* function/task prototypes */
   task void txDoneTask();
   task void signalStartConfirmSuccessTask();
-  void prepareNextBeaconTransmission();
+  void nextRound();
+  void prepareBeaconTransmission();
   void continueStartRequest();
   void finishRealignment(ieee154_txframe_t *frame, ieee154_status_t status);
 
@@ -242,7 +240,7 @@ implementation
       if (m_beaconOrder == 15) {
         // We're not already transmitting beacons, i.e. we have to request the token
         // (otherwise we'd get the token "automatically" for the next scheduled beacon).
-        call Token.request();
+        call RadioToken.request();
       }
       // We'll continue the MLME_START operation in continueStartRequest() once we have the token
     }
@@ -373,59 +371,61 @@ implementation
     }
   }
 
-  task void grantedTask()
+  task void signalGrantedTask()
   {
-    signal Token.granted();
+    signal RadioToken.granted();
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
-    dbg_serial("BeaconSynchronizeP","Got token, will Tx beacon in %lu\n",
-        (uint32_t) ((m_lastBeaconTxTime + m_dt) - call BeaconSendAlarm.getNow())); 
+    dbg_serial("BeaconSynchronizeP","Token granted.\n");
     if (m_requestBitmap & REQUEST_REALIGNMENT_DONE_PENDING) {
-      // unlikely to occur: we have not yet received a done()
+      // very unlikely: we have not yet received a done()
       // event after sending out a realignment frame 
       dbg_serial("BeaconTransmitP", "Realignment pending (request: %lu) !\n", (uint32_t) m_requestBitmap);
-      post grantedTask(); // spin
+      post signalGrantedTask(); // spin
       return;
     } else if (m_requestBitmap & REQUEST_UPDATE_SF) {
       dbg_serial("BeaconTransmitP","Putting new superframe spec into operation\n"); 
       m_requestBitmap &= ~REQUEST_UPDATE_SF;
       continueStartRequest();
     }
+    nextRound();
+  }
+
+  void nextRound()
+  {
     if (call RadioOff.isOff())
-      prepareNextBeaconTransmission();
+      prepareBeaconTransmission();
     else
-      ASSERT(call RadioOff.off() == SUCCESS); // will continue in prepareNextBeaconTransmission()
+      ASSERT(call RadioOff.off() == SUCCESS); // will continue in prepareBeaconTransmission()
   }
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClientID)
   {
-    if (call IsTokenRequested.getNow()) {
-      // some other component needs the token - we give it up for now, 
-      // but before make another request to get it back afterwards     
-      dbg_serial("BeaconTransmitP", "Token is requested, releasing it now.\n");
-      call Token.request();
-      call Token.release();
-    } else
-      post grantedTask();
+    dbg_serial("BeaconSynchronizeP","Token transferred, will Tx beacon in %lu\n",
+        (uint32_t) ((m_lastBeaconTxTime + m_dt) - call BeaconSendAlarm.getNow())); 
+    if (m_requestBitmap & (REQUEST_REALIGNMENT_DONE_PENDING | REQUEST_UPDATE_SF))
+      post signalGrantedTask(); // need to be in sync context
+    else
+      nextRound();
   }  
 
   async event void RadioOff.offDone()
   {
-    prepareNextBeaconTransmission();
+    prepareBeaconTransmission();
   }
 
-  void prepareNextBeaconTransmission()
+  void prepareBeaconTransmission()
   {
     if (m_txState == S_TX_LOCKED) {
       // have not had time to finish processing the last sent beacon
       dbg_serial("BeaconTransmitP", "Token was returned too fast!\n");
-      post grantedTask();
+      post signalGrantedTask();
     } else if (m_beaconOrder == 15) {
       // we're not sending any beacons!?
       dbg_serial("BeaconTransmitP", "Stop sending beacons.\n");
-      call Token.release();
+      call RadioToken.release();
     } else {
       // get ready for next beacon transmission
       atomic {
@@ -516,12 +516,12 @@ implementation
       dbg_serial("BeaconTransmitP", "Beacon Tx success at %lu\n", (uint32_t) m_lastBeaconTxTime);
     } else {
       // Timestamp is invalid; this is bad. We need the beacon timestamp for the 
-      // slotted CSMA-CA, because it defines slot reference time. We can't use this superframe
+      // slotted CSMA-CA, because it defines the slot reference time. We can't use this superframe
       // TODO: check if this was the initial beacon (then m_lastBeaconTxRefTime is invalid)
       dbg_serial("BeaconTransmitP", "Invalid timestamp!\n");
       m_dt += m_beaconInterval;
-      call Token.request();
-      call Token.release();      
+      call RadioToken.request();
+      call RadioToken.release();      
       return;
     }
 
@@ -547,7 +547,11 @@ implementation
       m_battLifeExtDuration = m_battLifeExtDuration + m_battLifeExtPeriods * 20;
     } else
       m_battLifeExtDuration = 0;
-    call TokenToBroadcast.transfer(); 
+
+    // we pass on the token now, but make a reservation to get it back 
+    // to transmit the next beacon (at the start of the next superframe)
+    call RadioToken.request();  
+    call RadioToken.transferTo(RADIO_CLIENT_COORDBROADCAST); 
     post txDoneTask();
   }
 
index 43bc855490574e5d692fc3f9a4e038a7fc755f84..e6000157fbaac0a06b045ac5b5a1e1071499f009 100644 (file)
@@ -49,10 +49,8 @@ module CoordBroadcastP
   } uses {
     interface Queue<ieee154_txframe_t*>; 
     interface FrameTxNow as CapTransmitNow;
-    interface ResourceTransfer as TokenToCap;
-    interface ResourceTransferred as TokenTransferred;
+    interface TransferableResource as RadioToken;
     interface SuperframeStructure as OutgoingSF;
-    interface Leds;
   }
 }
 implementation
@@ -106,7 +104,7 @@ implementation
       return (m_realignmentFrame != NULL || m_queueHead != NULL);
   }
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClient)
   {
     // CAP has started - are there any broadcast frames to be transmitted?
     if (call OutgoingSF.isBroadcastPending()) {
@@ -117,7 +115,7 @@ implementation
       m_lock = TRUE;
       call CapTransmitNow.transmitNow(broadcastFrame);
     }
-    call TokenToCap.transfer();
+    call RadioToken.transferTo(RADIO_CLIENT_COORDCAP);
   }
 
   async event void CapTransmitNow.transmitNowDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
@@ -141,4 +139,6 @@ implementation
     }
     m_lock = FALSE;
   }
+
+  event void RadioToken.granted(){ ASSERT(0); }
 }
index af60e699a50e4bfaab4744a1b5cadaf02e769eb2..1153b7a41a6a8fcb4225db3f9980188771678274 100644 (file)
@@ -272,5 +272,7 @@ implementation
 
   default event message_t* MCPS_DATA.indication(message_t* frame) { return frame; }
   default command ieee154_status_t DeviceCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
+  default command ieee154_status_t BroadcastTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_PARAMETER;}
   default command ieee154_status_t CoordCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
+  default async command bool IsSendingBeacons.getNow() {return FALSE;}
 }
index 9c1ad6a5044ed83c9afaa96ee7004c837592a01b..9d551042bb4e16dacaea188d9988a73304600a48 100644 (file)
@@ -77,11 +77,9 @@ generic module DispatchSlottedCsmaP(uint8_t sfDirection)
     interface Alarm<TSymbolIEEE802154,uint32_t> as BLEAlarm;
     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 TransferableResource as RadioToken;
     interface SuperframeStructure; 
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
     interface GetNow<bool> as IsRxEnableActive; 
     interface Get<ieee154_txframe_t*> as GetIndirectTxFrame; 
     interface Notify<bool> as RxEnableStateChange;
@@ -117,6 +115,7 @@ implementation
   enum {
     COORD_ROLE = (sfDirection == OUTGOING_SUPERFRAME),
     DEVICE_ROLE = !COORD_ROLE,
+    RADIO_CLIENT_CFP = COORD_ROLE ? RADIO_CLIENT_COORDCFP : RADIO_CLIENT_DEVICECFP,
   };
 
   /* state / frame management */
@@ -188,7 +187,7 @@ implementation
     return SUCCESS;
   }
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClient)
   {
     // we got the token, i.e. CAP has just started
     uint32_t capDuration = (uint32_t) call SuperframeStructure.numCapSlots() * 
@@ -212,7 +211,7 @@ implementation
     } else if (capDuration < guardTime) {
       // CAP is too short to do anything practical
       dbg_serial("DispatchSlottedCsmaP", "CAP too short!\n");
-      call TokenToCfp.transfer();
+      call RadioToken.transferTo(RADIO_CLIENT_CFP);
       return;
     } else {
       capDuration -= guardTime;
@@ -343,7 +342,7 @@ implementation
     atomic {
       // long atomics are bad... but in this block, once the/ current state has
       // been determined only one branch will/ be taken (there are no loops)
-      if (m_lock || !call Token.isOwner())
+      if (m_lock || !call RadioToken.isOwner())
         return;
       m_lock = TRUE; // lock
       capDuration = (uint32_t) call SuperframeStructure.numCapSlots() * 
@@ -369,7 +368,7 @@ implementation
           m_lock = FALSE; // unlock
           dbg_flush_state();
           dbg_serial("DispatchSlottedCsmaP", "Handing over to CFP.\n");
-          call TokenToCfp.transfer();
+          call RadioToken.transferTo(RADIO_CLIENT_CFP);
           return;
         } else 
           next = SWITCH_OFF;
@@ -394,14 +393,14 @@ implementation
       }
 
       // Check 4: is some other operation (like MLME-SCAN or MLME-RESET) pending? 
-      else if (call IsTokenRequested.getNow()) {
+      else if (call IsRadioTokenRequested.getNow()) {
         dbg_push_state(4);
         if (call RadioOff.isOff()) {
           stopAllAlarms();  // may still fire, but is locked through isOwner()
           // nothing more to do... just release the Token
           m_lock = FALSE; // unlock
           dbg_serial("DispatchSlottedCsmaP", "Token requested: Handing over to CFP.\n");
-          call TokenToCfp.transfer();
+          call RadioToken.release();
           return;
         } else 
           next = SWITCH_OFF;
@@ -439,14 +438,6 @@ implementation
       else {
         dbg_push_state(8);
         next = trySwitchOff();
-        if (next == DO_NOTHING && (DEVICE_ROLE && capDuration == 0)) {
-          // nothing more to do... just release the Token
-          stopAllAlarms();  // may still fire, but is locked through isOwner()
-          m_lock = FALSE; // unlock
-          dbg_serial("DispatchSlottedCsmaP", "Releasing token\n");
-          call Token.release();
-          return;
-        }
       }
 
       // if there is nothing to do, then we must clear the lock
@@ -697,7 +688,7 @@ implementation
     // only once per CAP (max. one broadcast is allowed after a beacon
     // transmission)
     atomic {
-      if (!call Token.isOwner() && m_bcastFrame == NULL) {
+      if (!call RadioToken.isOwner() && m_bcastFrame == NULL) {
         m_bcastFrame = frame;
         return IEEE154_SUCCESS;
       } else {
@@ -717,7 +708,7 @@ implementation
     signal WasRxEnabled.notify(TRUE);
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     ASSERT(0); // should never happen
   }
index cb00450b9ceb112115b2845f8bd580a68e644eca..7c916dc2490cb6f0de03077b84bc5ffaf20df46e 100644 (file)
@@ -64,8 +64,8 @@ module DispatchUnslottedCsmaP
   uses
   {
     interface Timer<TSymbolIEEE802154> as IndirectTxWaitTimer;
-    interface Resource as Token;
-    interface GetNow<bool> as IsTokenRequested;
+    interface TransferableResource as RadioToken;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
     interface GetNow<bool> as IsRxEnableActive; 
     interface Set<ieee154_macSuperframeOrder_t> as SetMacSuperframeOrder;
     interface Set<ieee154_macPanCoordinator_t> as SetMacPanCoordinator;     
@@ -191,12 +191,12 @@ implementation
       return IEEE154_TRANSACTION_OVERFLOW;
     } else {
       setCurrentFrame(frame);
-      call Token.request();
+      call RadioToken.request();
       return IEEE154_SUCCESS;
     }
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     updateState();
   }
@@ -248,7 +248,7 @@ implementation
       // long atomics are bad... but in this block, once the
       // current state has been determined only one branch will
       // be taken (there are no loops)
-      if (m_lock || !call Token.isOwner())
+      if (m_lock || !call RadioToken.isOwner())
         return;
       m_lock = TRUE; // lock
 
@@ -259,12 +259,12 @@ implementation
       }
 
       // Check 2: is some other operation (like MLME-SCAN or MLME-RESET) pending? 
-      else if (call IsTokenRequested.getNow()) {
+      else if (call IsRadioTokenRequested.getNow()) {
         if (call RadioOff.isOff()) {
           // nothing more to do... just release the Token
           m_lock = FALSE; // unlock
           dbg_serial("DispatchUnslottedCsmaP", "Token requested: releasing it.\n");
-          call Token.release();
+          call RadioToken.release();
           return;
         } else 
           next = SWITCH_OFF;
@@ -286,14 +286,14 @@ implementation
         }
       }
 
-      // Check 6: just make sure the radio is switched off  
+      // Check 5: just make sure the radio is switched off  
       else {
         next = trySwitchOff();
         if (next == DO_NOTHING) {
           // nothing more to do... just release the Token
           m_lock = FALSE; // unlock
           dbg_serial("DispatchUnslottedCsmaP", "Releasing token\n");
-          call Token.release();
+          call RadioToken.release();
           return;
         }
       }
@@ -357,7 +357,12 @@ implementation
 
   async event void RadioOff.offDone() { m_lock = FALSE; updateState();}
   async event void RadioRx.enableRxDone() { m_lock = FALSE; updateState();}
-  event void RxEnableStateChange.notify(bool whatever) { updateState();}
+  event void RxEnableStateChange.notify(bool whatever) { 
+    if (!call RadioToken.isOwner())
+      call RadioToken.request();
+    else
+      updateState();
+  }
 
   event void IndirectTxWaitTimer.fired() 
   { 
@@ -458,6 +463,8 @@ implementation
     uint8_t *payload = (uint8_t *) frame->data;
     uint8_t *mhr = MHR(frame);
     uint8_t frameType = mhr[MHR_INDEX_FC1] & FC1_FRAMETYPE_MASK;
+
+    dbg("DispatchUnslottedCsmaP", "Received frame, DSN: %lu, result: 0x%lx\n", (uint32_t) mhr[MHR_INDEX_SEQNO]);
     if (frameType == FC1_FRAMETYPE_CMD)
       frameType += payload[0];
     atomic {
@@ -494,4 +501,5 @@ implementation
   command error_t WasRxEnabled.enable() {return FAIL;}
   command error_t WasRxEnabled.disable() {return FAIL;}
   default event void MLME_START.confirm(ieee154_status_t status) {}
+  async event void RadioToken.transferredFrom(uint8_t fromClientID) {ASSERT(0);}
 }
index b4e7f6f9a37a64206c3ad0a9a474443008ff8b08..645b0e57ee7e1a390a8888b4cc54c8d00ad8b8bc 100644 (file)
@@ -55,6 +55,7 @@ module PibP {
     interface IEEE154Frame as Frame;
     interface IEEE154BeaconFrame as BeaconFrame;
     interface Get<uint64_t> as GetLocalExtendedAddress;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
     interface Notify<const void*> as PIBUpdate[uint8_t PIBAttributeID];
     interface Packet;
     interface TimeCalc;
@@ -67,7 +68,7 @@ module PibP {
     interface Init as MacReset;
     interface SplitControl as RadioControl;
     interface Random;
-    interface Resource as Token;
+    interface TransferableResource as RadioToken;
     interface RadioOff;
     interface LocalTime<TSymbolIEEE802154>;
   }
@@ -77,7 +78,7 @@ implementation
   ieee154_PIB_t m_pib;
   uint8_t m_numResetClientPending;
   bool m_setDefaultPIB;
-  uint8_t m_resetSpin;
+  norace uint8_t m_resetSpin;
 
 #ifdef IEEE154_EXTENDED_ADDRESS
   const uint64_t m_aExtendedAddressLE = IEEE154_EXTENDED_ADDRESS;
@@ -95,9 +96,7 @@ implementation
   command error_t LocalInit.init()
   {
 #ifndef IEEE154_EXTENDED_ADDRESS
-    uint32_t *p = (uint32_t*) &m_aExtendedAddressLE;
-    *p++ = call Random.rand32();
-    *p = call Random.rand32();
+    m_aExtendedAddressLE = (((uint64_t) call Random.rand32() ) << 32 ) | call Random.rand32(); 
 #endif
     resetAttributesToDefault();
     return SUCCESS;
@@ -175,15 +174,15 @@ implementation
       status = IEEE154_TRANSACTION_OVERFLOW; // must first cancel promiscuous mode!
     else {
       m_setDefaultPIB = SetDefaultPIB;
-      if (!call Token.isOwner())
-        call Token.request();
+      m_resetSpin = 5;
+      call RadioToken.request();
     }   
     dbg_serial("PibP", "MLME_RESET.request(%lu) -> result: %lu\n", 
         (uint32_t) SetDefaultPIB, (uint32_t) status);
     return status;
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     if (call RadioOff.off() != SUCCESS)
       signal RadioOff.offDone();
@@ -209,25 +208,21 @@ implementation
     call DispatchReset.init();       // resets the dispatch component(s), spools out frames
     call DispatchQueueReset.init();  // resets the dispatch queue component(s), spools out frames
     call MacReset.init();            // resets the remaining components
-    m_resetSpin = 5;
     post resetSpinTask();
   }
 
   task void resetSpinTask()
   {
-    if (m_resetSpin == 2) {
-      // just to be safe...
-      call DispatchReset.init();       
-      call DispatchQueueReset.init();  
-      call MacReset.init();       
-    }
-    if (m_resetSpin--) {
+    m_resetSpin -= 1;
+    if (m_resetSpin != 0) {
       post resetSpinTask();
       return;
     }
     ASSERT(call RadioControl.start() == SUCCESS);
   }
 
+  async command token_requested_t IsRadioTokenRequested.getNow(){ return m_resetSpin != 0; }
+
   event void RadioControl.startDone(error_t error)
   {
     if (m_setDefaultPIB)
@@ -242,7 +237,7 @@ implementation
       signal PIBUpdate.notify[IEEE154_macShortAddress](&m_pib.macShortAddress);
       signal PIBUpdate.notify[IEEE154_macPanCoordinator](&m_pib.macPanCoordinator);
     }
-    call Token.release();
+    call RadioToken.release();
     signal MLME_RESET.confirm(IEEE154_SUCCESS);
   }
   
@@ -1052,4 +1047,5 @@ implementation
   default event void PIBUpdate.notify[uint8_t PIBAttributeID](const void* PIBAttributeValue) {}
   command error_t PIBUpdate.enable[uint8_t PIBAttributeID]() {return FAIL;}
   command error_t PIBUpdate.disable[uint8_t PIBAttributeID]() {return FAIL;}
+  async event void RadioToken.transferredFrom(uint8_t fromClient){ASSERT(0);}
 }
index 76a7f743cb73f3526176f6df770aeb030be07ef5..2997f899524c307107f3d86820a184c338873eb9 100644 (file)
@@ -42,8 +42,9 @@ module PromiscuousModeP
     interface SplitControl as PromiscuousMode;
     interface Get<bool> as PromiscuousModeGet;
     interface FrameRx;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
   } uses {
-    interface Resource as Token;
+    interface TransferableResource as RadioToken;
     interface RadioRx as PromiscuousRx;
     interface RadioOff;
     interface Set<bool> as RadioPromiscuousMode;
@@ -76,14 +77,14 @@ implementation
     error_t result = FAIL;
     if (m_state == S_STOPPED) {
       m_state = S_STARTING;
-      call Token.request();
+      call RadioToken.request();
       result = SUCCESS;
     }
     dbg_serial("PromiscuousModeP", "PromiscuousMode.start -> result: %lu\n", (uint32_t) result);
     return result;
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     call RadioPromiscuousMode.set(TRUE);
     if (call RadioOff.isOff())
@@ -129,7 +130,7 @@ implementation
   {
     call RadioPromiscuousMode.set(FALSE);
     m_state = S_STOPPED;
-    call Token.release();
+    call RadioToken.release();
     dbg_serial("PromiscuousModeP", "Promiscuous mode disabled.\n");
     signal PromiscuousMode.stopDone(SUCCESS);
   }
@@ -142,6 +143,8 @@ implementation
       post continueStopTask();
   }
 
+  async command token_requested_t IsRadioTokenRequested.getNow(){ return m_state == S_STARTING; }
   default event void PromiscuousMode.startDone(error_t error) {}
   default event void PromiscuousMode.stopDone(error_t error) {}
+  async event void RadioToken.transferredFrom(uint8_t clientFrom){ASSERT(0);}
 }
index 4412d21a79de89b43efd5df59f8fc0a86e7fc737..8aabcf70c1e718fe0bcdb099e87a94d8a0b2bcaa 100644 (file)
@@ -34,7 +34,7 @@
  */
 
 #include "TKN154_MAC.h"
-generic configuration RadioClientC() 
+generic configuration RadioClientC(uint8_t clientID
 {
   provides
   {
@@ -43,38 +43,17 @@ generic configuration RadioClientC()
     interface RadioTx;
     interface SlottedCsmaCa;
     interface UnslottedCsmaCa;
-    interface Resource as Token;
-    interface ResourceRequested as TokenRequested;
-    interface ResourceTransfer;
-    interface ResourceTransferred;
-    interface ResourceTransferConnector as TransferFrom;
-    interface GetNow<bool> as IsResourceRequested;
-  } uses {
-    interface ResourceTransferConnector as TransferTo;
+    interface TransferableResource as RadioToken;
   }
 }
 implementation
 {
-  enum {
-    CLIENT = unique(IEEE802154_RADIO_RESOURCE),
-  };
-
   components RadioControlP;
-  RadioRx = RadioControlP.RadioRx[CLIENT];
-  RadioTx = RadioControlP.RadioTx[CLIENT];
-  RadioOff = RadioControlP.RadioOff[CLIENT];
-  SlottedCsmaCa = RadioControlP.SlottedCsmaCa[CLIENT];
-  UnslottedCsmaCa = RadioControlP.UnslottedCsmaCa[CLIENT];
-  Token = RadioControlP.Token[CLIENT];
-  IsResourceRequested = RadioControlP.IsResourceRequested;
-  TokenRequested = RadioControlP.TokenRequested[CLIENT];
-
-  components new TransferClientP(CLIENT);
-  ResourceTransfer = TransferClientP;
-  ResourceTransferred = TransferClientP;
-  TransferTo = TransferClientP;
-  TransferFrom = TransferClientP;
-  TransferClientP.ResourceTransferControl -> RadioControlP;
-  TransferClientP.Leds -> RadioControlP;
+  RadioRx = RadioControlP.RadioRx[clientID];
+  RadioTx = RadioControlP.RadioTx[clientID];
+  RadioOff = RadioControlP.RadioOff[clientID];
+  SlottedCsmaCa = RadioControlP.SlottedCsmaCa[clientID];
+  UnslottedCsmaCa = RadioControlP.UnslottedCsmaCa[clientID];
+  RadioToken = RadioControlP.TransferableResource[clientID];
 }
 
index 08742945fabf323b0127c28eb4b1e6201d815c86..a9e9a2e3c486ec326e6a0bdeb0bcae934ca83e16 100644 (file)
@@ -42,11 +42,8 @@ configuration RadioControlP
     interface SlottedCsmaCa as SlottedCsmaCa[uint8_t client];
     interface UnslottedCsmaCa as UnslottedCsmaCa[uint8_t client];
     interface RadioOff as RadioOff[uint8_t client];
-    interface Resource as Token[uint8_t client];
-    interface ResourceRequested as TokenRequested[uint8_t client];
-    interface ResourceTransferControl as TokenTransferControl;
-    interface GetNow<bool> as IsResourceRequested;
-    interface Leds as LedsRadioClient;
+    interface TransferableResource[uint8_t id];
+    interface ResourceRequested[uint8_t id];
   } uses {
     interface RadioRx as PhyRx;
     interface RadioTx as PhyTx;
@@ -54,6 +51,7 @@ configuration RadioControlP
     interface UnslottedCsmaCa as PhyUnslottedCsmaCa;
     interface RadioOff as PhyRadioOff;
     interface Get<bool> as RadioPromiscuousMode;
+    interface ResourceConfigure[uint8_t id];
     interface Leds;
   }
 }
@@ -72,12 +70,17 @@ implementation
   PhyRadioOff = RadioControlImplP.PhyRadioOff;
   RadioPromiscuousMode = RadioControlImplP;
   Leds = RadioControlImplP;
-  LedsRadioClient = Leds;
 
-  components new SimpleRoundRobinTransferArbiterC(IEEE802154_RADIO_RESOURCE) as Arbiter;
-  Token = Arbiter;  
-  TokenRequested = Arbiter;
-  TokenTransferControl = Arbiter;
-  IsResourceRequested = Arbiter;
+  components MainC;
+  components new RoundRobinResourceQueueC(uniqueCount(IEEE802154_RADIO_RESOURCE)) as Queue;
+  components new SimpleTransferArbiterP() as Arbiter;
+
+  MainC.SoftwareInit -> Queue;
+
+  TransferableResource = Arbiter;
+  ResourceRequested = Arbiter;
   RadioControlImplP.ArbiterInfo -> Arbiter;
+  ResourceConfigure = Arbiter;
+
+  Arbiter.Queue -> Queue;
 }
index ce332ba2159931bf557ca2938def680b7a4cf4c9..87b5e6df3283e1b4c6c58d9c26763a2466ed0d05 100644 (file)
@@ -45,6 +45,7 @@ module ScanP
     interface Init;
     interface MLME_SCAN;
     interface MLME_BEACON_NOTIFY;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
   }
   uses
   {
@@ -59,7 +60,7 @@ module ScanP
     interface Timer<TSymbolIEEE802154> as ScanTimer;
     interface Pool<ieee154_txframe_t> as TxFramePool;
     interface Pool<ieee154_txcontrol_t> as TxControlPool;
-    interface Resource as Token;
+    interface TransferableResource as RadioToken;
     interface FrameUtility;
     interface Leds;
   }
@@ -83,7 +84,7 @@ implementation
   uint8_t m_resultIndex;
   ieee154_macPANId_t m_PANID;
   norace uint32_t m_scanDuration;
-  bool m_busy = FALSE;
+  norace bool m_busy = FALSE;
 
   void nextIteration();
   void continueScanRequest();
@@ -92,10 +93,10 @@ implementation
 
   command error_t Init.init()
   {
-    // triggered by MLME_RESET; remember: Init will not be called
-    // while this component owns the Token, so the worst case is 
+    // triggered by MLME_RESET; Note: Init will not be called
+    // while this component owns the RadioToken, so the worst case is 
     // that a MLME_SCAN was accepted (returned IEEE154_SUCCESS)  
-    // but the Token.granted() has not been signalled            
+    // but the RadioToken.granted() has not been signalled            
     if (m_busy) {
       m_currentChannelNum = 27;
       nextIteration(); // signals confirm and resets state
@@ -169,13 +170,13 @@ implementation
       }
       if (m_resultList == NULL)
         m_resultListNumEntries = 0;
-      call Token.request();
+      call RadioToken.request();
     }
     dbg_serial("ScanP", "MLME_SCAN.request -> result: %lu\n", (uint32_t) status);
     return status;
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
     if (call RadioOff.isOff())
       continueScanRequest();
@@ -196,7 +197,7 @@ implementation
     ieee154_macDSN_t dsn = call MLME_GET.macDSN();
 
     if (!m_busy) {
-      call Token.release();
+      call RadioToken.release();
       return;
     }
     switch (m_scanType) {
@@ -278,8 +279,8 @@ implementation
         call TxFramePool.put(m_txFrame);
       }
       m_txFrame = NULL;
-      if (call Token.isOwner())
-        call Token.release();
+      if (call RadioToken.isOwner())
+        call RadioToken.release();
       m_busy = FALSE;
       dbg_serial("ScanP", "MLME_SCAN.confirm()\n");
       signal MLME_SCAN.confirm (
@@ -288,12 +289,13 @@ implementation
           IEEE154_SUPPORTED_CHANNELPAGE,
           m_unscannedChannels,
           (m_scanType == ENERGY_DETECTION_SCAN) ? m_resultIndex : 0,
-          (m_scanType == ENERGY_DETECTION_SCAN) ? (uint8_t*) m_resultList : NULL,
+          (m_scanType == ENERGY_DETECTION_SCAN) ? (int8_t*) m_resultList : NULL,
           ((m_scanType == ACTIVE_SCAN ||
            m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? m_resultIndex : 0,
           ((m_scanType == ACTIVE_SCAN ||
            m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? (ieee154_PANDescriptor_t*) m_resultList : NULL);
     }
+    dbg_serial_flush();
   }
   
   async event void RadioRx.enableRxDone()
@@ -405,6 +407,8 @@ implementation
     nextIteration();
   }
 
+  async command token_requested_t IsRadioTokenRequested.getNow(){ return m_busy;}
+  async event void RadioToken.transferredFrom(uint8_t id){ ASSERT(0);}
   default event message_t* MLME_BEACON_NOTIFY.indication (message_t *beaconFrame) {return beaconFrame;}
   default event void MLME_SCAN.confirm    (
                           ieee154_status_t status,
diff --git a/tos/lib/mac/tkn154/SimpleRoundRobinTransferArbiterC.nc b/tos/lib/mac/tkn154/SimpleRoundRobinTransferArbiterC.nc
deleted file mode 100644 (file)
index fa43524..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * "Copyright (c) 2005 Washington University in St. Louis.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY 
- * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING 
- * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON 
- * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO 
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
- * MODIFICATIONS."
- */
-/*
- * Copyright (c) 2004, Technische Universitat Berlin
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitat Berlin nor the names
- *   of its contributors may be used to endorse or promote products derived
- *   from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-/**
- * Please refer to TEP 108 for more information about this component and its
- * intended use.<br><br>
- *
- * This component provides the Resource, ArbiterInfo, and Resource
- * Controller interfaces and uses the ResourceConfigure interface as
- * described in TEP 108.  It provides arbitration to a shared resource in
- * an FCFS fashion.  An array is used to keep track of which users have put
- * in requests for the resource.  Upon the release of the resource by one
- * of these users, the array is checked and the next user (in FCFS order)
- * that has a pending request will ge granted control of the resource.  If
- * there are no pending requests, then the resource becomes idle and any
- * user can put in a request and immediately receive access to the
- * Resource.
- *
- * @param <b>resourceName</b> -- The name of the Resource being shared
- * 
- * @author Kevin Klues (klues@tkn.tu-berlin.de)
- * @author Philip Levis
- */
-generic configuration SimpleRoundRobinTransferArbiterC(char resourceName[]) {
-  provides {
-    interface Resource[uint8_t id];
-    interface ResourceRequested[uint8_t id];
-    interface ResourceTransferControl;
-    interface ArbiterInfo;
-    interface GetNow<bool> as IsResourceRequested;
-  }
-  uses interface ResourceConfigure[uint8_t id];
-}
-implementation {
-  components MainC;
-  components new RoundRobinResourceQueueC(uniqueCount(resourceName)) as Queue;
-  components new SimpleTransferArbiterP() as Arbiter;
-
-  MainC.SoftwareInit -> Queue;
-
-  Resource = Arbiter;
-  ResourceRequested = Arbiter;
-  ArbiterInfo = Arbiter;
-  ResourceConfigure = Arbiter;
-  ResourceTransferControl = Arbiter;
-  IsResourceRequested = Arbiter;
-
-  Arbiter.Queue -> Queue;
-}
index 7cb1427d4bf9c4a005c526ca66e0729449181d28..1262c5a2ff47b3cc8a1d5a8db4fd66cbe48207fc 100644 (file)
  * 
  * @author Kevin Klues (klues@tkn.tu-berlin.de)
  * @author Philip Levis
- * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (added resource transfer)
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (added TransferableResource interface)
  */
  
 generic module SimpleTransferArbiterP() {
   provides {
-    interface Resource[uint8_t id];
+    interface TransferableResource as Resource[uint8_t id];
     interface ResourceRequested[uint8_t id];
-    interface ResourceTransferControl;
     interface ArbiterInfo;
-    interface GetNow<bool> as IsResourceRequested;
   }
   uses {
     interface ResourceConfigure[uint8_t id];
@@ -120,18 +118,14 @@ implementation {
     return FAIL;
   }
 
-  async command bool IsResourceRequested.getNow()
-  {
-    return !(call Queue.isEmpty());
-  }
-
-  async command error_t ResourceTransferControl.transfer(uint8_t fromClient, uint8_t toClient)
+  async command error_t Resource.transferTo[uint8_t fromID](uint8_t toID)
   {
     atomic {
-      if (call ArbiterInfo.userId() == fromClient) {
-        call ResourceConfigure.unconfigure[fromClient]();
+      if (call ArbiterInfo.userId() == fromID) {
+        call ResourceConfigure.unconfigure[fromID]();
         call ResourceConfigure.configure[resId]();
-        resId = toClient;
+        resId = toID;
+        signal Resource.transferredFrom[toID](fromID); // consider moving this outside the atomic
         return SUCCESS;
       }
     }
@@ -192,4 +186,6 @@ implementation {
   }
   default async command void ResourceConfigure.unconfigure[uint8_t id]() {
   }
+  default async event void Resource.transferredFrom[uint8_t id](uint8_t c) {
+  }
 }
index ea794c3b5add1f54eb3b1082011d84b32cb7bbf6..4b1b307afe3b18ee311672bc6f15fd7ca2317c0e 100644 (file)
@@ -222,7 +222,7 @@ implementation
   
   /* ----------------------- Scanning (MLME-SCAN) ----------------------- */
 
-  components new RadioClientC() as ScanRadioClient;
+  components new RadioClientC(RADIO_CLIENT_SCAN) as ScanRadioClient;
   PibP.MacReset -> ScanP;
   ScanP.MLME_GET -> PibP;
   ScanP.MLME_SET -> PibP.MLME_SET;
@@ -235,13 +235,13 @@ implementation
   ScanP.ScanTimer = Timer1;
   ScanP.TxFramePool -> TxFramePoolP;
   ScanP.TxControlPool -> TxControlPoolP;
-  ScanP.Token -> ScanRadioClient;
+  ScanP.RadioToken -> ScanRadioClient;
   ScanP.Leds = Leds;
   ScanP.FrameUtility -> PibP;
 
   /* ----------------- Beacon Transmission (MLME-START) ----------------- */
   
-  components new RadioClientC() as BeaconTxRadioClient;
+  components new RadioClientC(RADIO_CLIENT_BEACONTRANSMIT) as BeaconTxRadioClient;
   PibP.MacReset -> BeaconTransmitP;
   BeaconTransmitP.PIBUpdate[IEEE154_macAssociationPermit] -> PibP.PIBUpdate[IEEE154_macAssociationPermit];
   BeaconTransmitP.PIBUpdate[IEEE154_macGTSPermit] -> PibP.PIBUpdate[IEEE154_macGTSPermit];
@@ -254,10 +254,7 @@ implementation
   BeaconTransmitP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder;
   BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
   BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
-  BeaconTransmitP.Token -> BeaconTxRadioClient;
-  BeaconTransmitP.IsTokenRequested -> BeaconTxRadioClient;
-  BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
-  BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
+  BeaconTransmitP.RadioToken -> BeaconTxRadioClient;
   BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
   BeaconTransmitP.RealignmentNonBeaconEnabledTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
   BeaconTransmitP.BeaconRequestRx -> CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_BEACON_REQUEST];
@@ -271,11 +268,10 @@ implementation
   BeaconTransmitP.IsBroadcastReady -> CoordBroadcastP.IsBroadcastReady;
   BeaconTransmitP.TimeCalc -> PibP;
   BeaconTransmitP.Leds = Leds;
-  BeaconTxRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
 
   /* ------------------ Beacon Tracking (MLME-SYNC) ------------------ */
 
-  components new RadioClientC() as SyncRadioClient;
+  components new RadioClientC(RADIO_CLIENT_BEACONSYNCHRONIZE) as SyncRadioClient;
   PibP.MacReset -> BeaconSynchronizeP;
   BeaconSynchronizeP.MLME_SET -> PibP.MLME_SET;
   BeaconSynchronizeP.MLME_GET -> PibP;
@@ -286,14 +282,10 @@ implementation
   BeaconSynchronizeP.BeaconRx -> SyncRadioClient;
   BeaconSynchronizeP.RadioOff -> SyncRadioClient;
   BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_POLL_CLIENT];
-  BeaconSynchronizeP.Token -> SyncRadioClient;
-  BeaconSynchronizeP.IsTokenRequested -> SyncRadioClient;
-  BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
-  BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
+  BeaconSynchronizeP.RadioToken -> SyncRadioClient;
   BeaconSynchronizeP.TimeCalc -> PibP;
   BeaconSynchronizeP.CoordRealignmentRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_COORDINATOR_REALIGNMENT];
   BeaconSynchronizeP.Leds = Leds;
-  SyncRadioClient.TransferTo -> DeviceCapRadioClient.TransferFrom;
 
   /* -------------------- Association (MLME-ASSOCIATE) -------------------- */
 
@@ -390,15 +382,12 @@ implementation
 
   /* ---------------------------- Broadcasts ---------------------------- */
 
-  components new RadioClientC() as CoordBroadcastRadioClient;
+  components new RadioClientC(RADIO_CLIENT_COORDBROADCAST) as CoordBroadcastRadioClient;
   PibP.MacReset -> CoordBroadcastP;
-  CoordBroadcastP.TokenTransferred -> CoordBroadcastRadioClient;
-  CoordBroadcastP.TokenToCap -> CoordBroadcastRadioClient;
-  CoordBroadcastRadioClient.TransferTo -> CoordCapRadioClient.TransferFrom;
+  CoordBroadcastP.RadioToken -> CoordBroadcastRadioClient;
   CoordBroadcastP.OutgoingSF -> BeaconTransmitP.OutgoingSF;
   CoordBroadcastP.CapTransmitNow -> CoordCap.BroadcastTx;
   CoordBroadcastP.Queue -> BroadcastQueueC;
-  CoordBroadcastP.Leds = Leds;
 
   /* --------------------- CAP (incoming superframe) -------------------- */
 
@@ -410,18 +399,18 @@ implementation
   CoordCapQueue.Queue -> CoordCapQueueC;
   CoordCapQueue.FrameTxCsma -> CoordCap;
   
-  components new RadioClientC() as DeviceCapRadioClient;
+  components new RadioClientC(RADIO_CLIENT_DEVICECAP) as DeviceCapRadioClient;
   PibP.DispatchReset -> DeviceCap;
   DeviceCap.CapEndAlarm = Alarm3;
   DeviceCap.BLEAlarm = Alarm4;
   DeviceCap.IndirectTxWaitAlarm = Alarm5;
   DeviceCap.BroadcastAlarm = Alarm6;
-  DeviceCap.Token -> DeviceCapRadioClient;
-  DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
-  DeviceCap.TokenToCfp -> DeviceCapRadioClient;
-  DeviceCap.TokenTransferred -> DeviceCapRadioClient;
+  DeviceCap.RadioToken -> DeviceCapRadioClient;
   DeviceCap.SuperframeStructure -> BeaconSynchronizeP.IncomingSF;
   DeviceCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+  DeviceCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+  DeviceCap.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+  DeviceCap.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
   DeviceCap.GetIndirectTxFrame -> IndirectTxP;
   DeviceCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange;  
   DeviceCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;  
@@ -434,21 +423,20 @@ implementation
   DeviceCap.TimeCalc -> PibP;
   DeviceCap.Leds = Leds;
   DeviceCap.TrackSingleBeacon -> BeaconSynchronizeP.TrackSingleBeacon;
-  DeviceCapRadioClient.TransferTo -> DeviceCfpRadioClient.TransferFrom;
 
   /* ---------------------- CAP (outgoing superframe) ------------------- */
 
-  components new RadioClientC() as CoordCapRadioClient, 
+  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.Token -> CoordCapRadioClient;
-  CoordCap.TokenToCfp -> CoordCapRadioClient;
-  CoordCap.TokenTransferred -> CoordCapRadioClient;
-  CoordCap.IsTokenRequested -> CoordCapRadioClient;
+  CoordCap.RadioToken -> CoordCapRadioClient;
   CoordCap.SuperframeStructure -> BeaconTransmitP.OutgoingSF;
   CoordCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+  CoordCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+  CoordCap.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+  CoordCap.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
   CoordCap.GetIndirectTxFrame -> IndirectTxP;
   CoordCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange;  
   CoordCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;  
@@ -460,17 +448,14 @@ implementation
   CoordCap.MLME_SET -> PibP.MLME_SET;
   CoordCap.TimeCalc -> PibP;
   CoordCap.Leds = Leds;
-  CoordCapRadioClient.TransferTo -> CoordCfpRadioClient.TransferFrom;
   CoordCap.FrameBackup -> BackupP;
   CoordCap.FrameRestore -> BackupP;
 
   /* -------------------- GTS (incoming superframe) --------------------- */
 
-  components new RadioClientC() as DeviceCfpRadioClient;
+  components new RadioClientC(RADIO_CLIENT_DEVICECFP) as DeviceCfpRadioClient;
   PibP.MacReset -> DeviceCfp;
-  DeviceCfp.TokenTransferred -> DeviceCfpRadioClient;
-  DeviceCfp.TokenRequested -> DeviceCfpRadioClient;
-  DeviceCfp.TokenToBeaconSync -> DeviceCfpRadioClient;
+  DeviceCfp.RadioToken -> DeviceCfpRadioClient;
   DeviceCfp.IncomingSF -> BeaconSynchronizeP.IncomingSF; 
   DeviceCfp.CfpSlotAlarm = Alarm9;
   DeviceCfp.CfpEndAlarm = Alarm10;
@@ -479,15 +464,12 @@ implementation
   DeviceCfp.RadioOff -> DeviceCfpRadioClient;
   DeviceCfp.MLME_GET -> PibP;
   DeviceCfp.MLME_SET -> PibP.MLME_SET; 
-  DeviceCfpRadioClient.TransferTo -> SyncRadioClient.TransferFrom;
 
   /* -------------------- GTS (outgoing superframe) --------------------- */
 
-  components new RadioClientC() as CoordCfpRadioClient;
+  components new RadioClientC(RADIO_CLIENT_COORDCFP) as CoordCfpRadioClient;
   PibP.MacReset -> CoordCfp;
-  CoordCfp.TokenTransferred -> CoordCfpRadioClient;
-  CoordCfp.TokenRequested -> CoordCfpRadioClient;
-  CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
+  CoordCfp.RadioToken -> CoordCfpRadioClient;
   CoordCfp.OutgoingSF -> BeaconTransmitP.OutgoingSF; 
   CoordCfp.CfpSlotAlarm = Alarm11;
   CoordCfp.CfpEndAlarm = Alarm12;
@@ -496,13 +478,12 @@ implementation
   CoordCfp.RadioOff -> CoordCfpRadioClient;
   CoordCfp.MLME_GET -> PibP;
   CoordCfp.MLME_SET -> PibP.MLME_SET;
-  CoordCfpRadioClient.TransferTo -> BeaconTxRadioClient.TransferFrom;
 
   /* -------------------------- promiscuous mode ------------------------ */
 
-  components new RadioClientC() as PromiscuousModeRadioClient;
+  components new RadioClientC(RADIO_CLIENT_PROMISCUOUSMODE) as PromiscuousModeRadioClient;
   PibP.MacReset -> PromiscuousModeP;
-  PromiscuousModeP.Token -> PromiscuousModeRadioClient;
+  PromiscuousModeP.RadioToken -> PromiscuousModeRadioClient;
   PromiscuousModeP.PromiscuousRx -> PromiscuousModeRadioClient;
   PromiscuousModeP.RadioOff -> PromiscuousModeRadioClient;
   PromiscuousModeP.RadioPromiscuousMode = RadioPromiscuousMode;
@@ -521,14 +502,14 @@ implementation
 
   /* ------------------------------- PIB -------------------------------- */
 
-  components new RadioClientC() as PibRadioClient;
+  components new RadioClientC(RADIO_CLIENT_PIB) as PibRadioClient;
   PIBUpdate = PibP;
   MainC.SoftwareInit -> PibP.LocalInit;
   PibP.RadioControl = PhySplitControl;
   PibP.Random = Random; 
   PibP.PromiscuousModeGet -> PromiscuousModeP; 
   PibP.LocalTime = LocalTime;
-  PibP.Token -> PibRadioClient;
+  PibP.RadioToken -> PibRadioClient;
   PibP.RadioOff -> PibRadioClient;
 
   /* ------------------------- Radio Control ---------------------------- */
index 9924fbd06b88e323d2bb5eaaa164715629fafefb..c294df78326f43e1daf6caaab3aace8c177d51ed 100644 (file)
@@ -174,7 +174,7 @@ implementation
   
   /* ----------------------- Scanning (MLME-SCAN) ----------------------- */
 
-  components new RadioClientC() as ScanRadioClient;
+  components new RadioClientC(RADIO_CLIENT_SCAN) as ScanRadioClient;
   PibP.MacReset -> ScanP;
   ScanP.MLME_GET -> PibP;
   ScanP.MLME_SET -> PibP.MLME_SET;
@@ -187,7 +187,7 @@ implementation
   ScanP.ScanTimer = Timer1;
   ScanP.TxFramePool -> TxFramePoolP;
   ScanP.TxControlPool -> TxControlPoolP;
-  ScanP.Token -> ScanRadioClient;
+  ScanP.RadioToken -> ScanRadioClient;
   ScanP.Leds = Leds;
   ScanP.FrameUtility -> PibP;
 
@@ -282,14 +282,16 @@ implementation
   DispatchQueueP.Queue -> DispatchQueueC;
   DispatchQueueP.FrameTxCsma -> DispatchP;
   
-  components new RadioClientC() as DispatchRadioClient;
+  components new RadioClientC(unique(IEEE802154_RADIO_RESOURCE)) as DispatchRadioClient;
   PibP.DispatchReset -> DispatchP;
   DispatchP.IndirectTxWaitTimer = Timer4;
-  DispatchP.Token -> DispatchRadioClient;
+  DispatchP.RadioToken -> DispatchRadioClient;
   DispatchP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder;
   DispatchP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
-  DispatchP.IsTokenRequested -> DispatchRadioClient;
   DispatchP.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+  DispatchP.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+  DispatchP.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+  DispatchP.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
   DispatchP.GetIndirectTxFrame -> IndirectTxP;
   DispatchP.RxEnableStateChange -> RxEnableP.RxEnableStateChange;  
   DispatchP.FrameUtility -> PibP;
@@ -303,9 +305,9 @@ implementation
 
   /* -------------------------- promiscuous mode ------------------------ */
 
-  components new RadioClientC() as PromiscuousModeRadioClient;
+  components new RadioClientC(RADIO_CLIENT_PROMISCUOUSMODE) as PromiscuousModeRadioClient;
   PibP.MacReset -> PromiscuousModeP;
-  PromiscuousModeP.Token -> PromiscuousModeRadioClient;
+  PromiscuousModeP.RadioToken -> PromiscuousModeRadioClient;
   PromiscuousModeP.PromiscuousRx -> PromiscuousModeRadioClient;
   PromiscuousModeP.RadioOff -> PromiscuousModeRadioClient;
   PromiscuousModeP.RadioPromiscuousMode = RadioPromiscuousMode;
@@ -320,14 +322,14 @@ implementation
 
   /* ------------------------------- PIB -------------------------------- */
 
-  components new RadioClientC() as PibRadioClient;
+  components new RadioClientC(RADIO_CLIENT_PIB) as PibRadioClient;
   PIBUpdate = PibP;
   MainC.SoftwareInit -> PibP.LocalInit;
   PibP.RadioControl = PhySplitControl;
   PibP.Random = Random; 
   PibP.PromiscuousModeGet -> PromiscuousModeP; 
   PibP.LocalTime = LocalTime;
-  PibP.Token -> PibRadioClient;
+  PibP.RadioToken -> PibRadioClient;
   PibP.RadioOff -> PibRadioClient;
 
   /* ------------------------- Radio Control ---------------------------- */
index 64d6af061e560e56fef9fa0f87eb19da5b857b8f..965e4c7534e98f1cb391a1067c1c56f894b81358 100644 (file)
@@ -135,6 +135,27 @@ enum {
 #define IEEE802154_RADIO_RESOURCE "RadioRxTxP.resource"
 
 enum {
+  // The following identfiers map to components that access the radio
+  // via RadioClientC(). They are used as parameters for RadioClientC(),
+  // the TransferableResource.transferTo() command and in
+  // the TransferableResource.transferredFrom() event
+
+  RADIO_CLIENT_SCAN = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_PIB = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_PROMISCUOUSMODE = unique(IEEE802154_RADIO_RESOURCE),
+
+  RADIO_CLIENT_BEACONTRANSMIT = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_COORDBROADCAST = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_COORDCAP = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_COORDCFP = unique(IEEE802154_RADIO_RESOURCE),
+
+  RADIO_CLIENT_BEACONSYNCHRONIZE = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_DEVICECAP = unique(IEEE802154_RADIO_RESOURCE),
+  RADIO_CLIENT_DEVICECFP = unique(IEEE802154_RADIO_RESOURCE),
+};
+
+enum {
+  // parameter for the generic DispatchSlottedCsmaP
   OUTGOING_SUPERFRAME,
   INCOMING_SUPERFRAME,
 };
@@ -258,6 +279,13 @@ enum {
   IEEE154_aUnitBackoffPeriod           = 20,
 };
 
+// combine function for IsRadioTokenRequested (GetNow) interface
+typedef bool token_requested_t __attribute__((combine(rcombine)));
+token_requested_t rcombine(token_requested_t r1, token_requested_t r2)
+{
+  return r1 && r2;
+}
+
 #ifdef TKN154_DEBUG
 
   /****************************************************************** 
diff --git a/tos/lib/mac/tkn154/TransferClientP.nc b/tos/lib/mac/tkn154/TransferClientP.nc
deleted file mode 100644 (file)
index 305750a..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/* 
- * Copyright (c) 2008, Technische Universitaet Berlin
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * - Redistributions of source code must retain the above copyright notice,
- *   this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitaet Berlin nor the names
- *   of its contributors may be used to endorse or promote products derived
- *   from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-generic module TransferClientP(uint8_t myUserId)
-{
-  provides
-  {
-    interface ResourceTransfer;
-    interface ResourceTransferred;
-    interface ResourceTransferConnector as TransferredFrom;
-  } uses {
-    interface ResourceTransferConnector as TransferTo;
-    interface ResourceTransferControl;
-    interface Leds;
-  }
-}
-implementation
-{
-  async command error_t ResourceTransfer.transfer()
-  {
-    error_t result;
-    uint8_t toClient = call TransferTo.getUserId();
-    atomic {
-      result = call ResourceTransferControl.transfer(myUserId, toClient);
-      if (result == SUCCESS)
-        call TransferTo.transfer();
-    }
-    return result;
-  }
-
-  async command uint8_t TransferredFrom.getUserId() { return myUserId;}
-
-  async command void TransferredFrom.transfer()
-  {
-    signal ResourceTransferred.transferred();
-  }
-  default async command uint8_t TransferTo.getUserId() { ASSERT(0); return 0xFF;}
-  default async command void TransferTo.transfer() { ASSERT(0); }
-  default async event void ResourceTransferred.transferred() {}
-}
index e1dee2c348621adbb683076d4e756af29135af58..30fa2ff7ccc53eb42e8934c715c2e9708b08b0e5 100644 (file)
@@ -60,10 +60,7 @@ module NoBeaconSynchronizeP
     interface RadioOff;
     interface DataRequest;
     interface FrameRx as CoordRealignmentRx;
-    interface Resource as Token;
-    interface GetNow<bool> as IsTokenRequested;
-    interface ResourceTransferred as TokenTransferred;
-    interface ResourceTransfer as TokenToCap;
+    interface TransferableResource as RadioToken;
     interface TimeCalc;
     interface IEEE154Frame as Frame;
     interface Leds;
@@ -78,9 +75,9 @@ implementation
     return IEEE154_TRANSACTION_OVERFLOW;
   }
 
-  event void Token.granted() { }
+  event void RadioToken.granted() { }
 
-  async event void TokenTransferred.transferred() { }
+  async event void RadioToken.transferredFrom(uint8_t fromClient) { call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT); }
 
   async event void RadioOff.offDone() { }
 
index 7d4a9f860a8e50e5ae8f34ca5c4a5fedd53be1c8..04f4a8997e882ec82e4aa0fca0ad78836c15ab61 100644 (file)
@@ -56,10 +56,7 @@ module NoBeaconTransmitP
     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 TransferableResource as RadioToken;
     interface FrameTx as RealignmentBeaconEnabledTx;
     interface FrameTx as RealignmentNonBeaconEnabledTx;
     interface FrameRx as BeaconRequestRx;
@@ -97,9 +94,9 @@ implementation
     return IEEE154_TRANSACTION_OVERFLOW;
   }
 
-  event void Token.granted() { }
+  event void RadioToken.granted() { }
 
-  async event void TokenTransferred.transferred() { call Token.release(); }
+  async event void RadioToken.transferredFrom(uint8_t from) { call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE); }
 
   async event void RadioOff.offDone() { }
 
index 5ebf2b180e59f9d1d56a4499cb958bf92d3c6728..93d6b99c065f2752ec409f314e0695705ea7814e 100644 (file)
@@ -47,8 +47,7 @@ module NoCoordBroadcastP
   } uses {
     interface Queue<ieee154_txframe_t*>; 
     interface FrameTxNow as CapTransmitNow;
-    interface ResourceTransfer as TokenToCap;
-    interface ResourceTransferred as TokenTransferred;
+    interface TransferableResource as RadioToken;
     interface GetNow<bool> as BeaconFramePendingBit;
     interface SuperframeStructure as OutgoingSF;
     interface Leds;
@@ -74,12 +73,13 @@ implementation
     return FALSE;
   }
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClient)
   {
-    call TokenToCap.transfer();
+    call RadioToken.transferTo(RADIO_CLIENT_COORDCAP);
   }
 
   async event void CapTransmitNow.transmitNowDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
   {
   }
+  event void RadioToken.granted(){ }
 }
index 45497e6aac02a1c48cf8b96e788d9a280fa4888b..b8ba907ffdb1d3a454290e6456b00087b8768bff 100644 (file)
@@ -52,9 +52,7 @@ module NoCoordCfpP
     interface FrameTx as CfpTx;
     interface Purge;
   } uses {
-    interface ResourceTransferred as TokenTransferred;
-    interface ResourceTransfer as TokenToBeaconTransmit;
-    interface ResourceRequested as TokenRequested;
+    interface TransferableResource as RadioToken;
     interface Alarm<TSymbolIEEE802154,uint32_t> as CfpSlotAlarm;
     interface Alarm<TSymbolIEEE802154,uint32_t> as CfpEndAlarm;
     interface SuperframeStructure as OutgoingSF; 
@@ -85,12 +83,15 @@ implementation
     return IEEE154_INVALID_HANDLE; 
   } 
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClient)
   {
     // the CFP has started, this component now owns the token -  
-    // because GTS is not implemented we pass it back to the
-    // BeaconTransmitP component
-    call TokenToBeaconTransmit.transfer();
+    // because GTS is not implemented we pass it on
+#ifndef IEEE154_BEACON_SYNC_DISABLED
+    call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE);
+#else
+    call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT);
+#endif
   }
 
   async event void CfpEndAlarm.fired() {}
@@ -120,12 +121,8 @@ implementation
   async event void RadioRx.enableRxDone(){} 
   event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp){return frame;}
 
-  async event void TokenRequested.requested()
+  event void RadioToken.granted()
   {
-    // 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(){ }
+    ASSERT(0); // should never happen, because we never call RadioToken.request()
+  }  
 }
index 9f6f87e63377c486075a2439cf085fbb6765f651..545c89ade8bb4235fdff3adedb2ff05aebccb3d0 100644 (file)
@@ -51,9 +51,7 @@ module NoDeviceCfpP
     interface FrameTx as CfpTx;
     interface Purge;
   } uses {
-    interface ResourceTransferred as TokenTransferred;
-    interface ResourceRequested as TokenRequested;
-    interface ResourceTransfer as TokenToBeaconSync;
+    interface TransferableResource as RadioToken;
     interface Alarm<TSymbolIEEE802154,uint32_t> as CfpSlotAlarm;
     interface Alarm<TSymbolIEEE802154,uint32_t> as CfpEndAlarm;
     interface SuperframeStructure as IncomingSF; 
@@ -84,12 +82,15 @@ implementation
     return IEEE154_INVALID_HANDLE; 
   } 
 
-  async event void TokenTransferred.transferred()
+  async event void RadioToken.transferredFrom(uint8_t fromClient)
   { 
     // the CFP has started, this component now owns the token -  
-    // because GTS is not implemented we pass it back to the
-    // BeaconTransmitP component
-    call TokenToBeaconSync.transfer();
+    // because GTS is not implemented we pass it on
+#ifndef IEEE154_BEACON_TX_DISABLED
+    call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT);
+#else
+    call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE);
+#endif
   }
 
   async event void CfpEndAlarm.fired() {}
@@ -102,12 +103,8 @@ implementation
   async event void RadioRx.enableRxDone(){} 
   event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp){return frame;} 
 
-  async event void TokenRequested.requested()
+  event void RadioToken.granted()
   {
-    // 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(){ }
+    ASSERT(0); // should never happen, because we never call RadioToken.request()
+  }   
 }
index 73d201efb6669e1b79a7a3bd78aadd7c15ec6935..b61259ecce4bf856afe4160cc13d96134cba62e5 100644 (file)
@@ -38,7 +38,7 @@
 #include "TKN154_PHY.h"
 #include "TKN154_MAC.h"
 
-generic module NoDispatchSlottedCsmaP(uint8_t superframeDirection)
+generic module NoDispatchSlottedCsmaP(uint8_t sfDirection)
 {
   provides
   {
@@ -55,10 +55,8 @@ generic module NoDispatchSlottedCsmaP(uint8_t superframeDirection)
     interface Alarm<TSymbolIEEE802154,uint32_t> as BLEAlarm;
     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 GetNow<token_requested_t> as IsRadioTokenRequested;
+    interface TransferableResource as RadioToken;
     interface SuperframeStructure; 
     interface GetNow<bool> as IsRxEnableActive; 
     interface Get<ieee154_txframe_t*> as GetIndirectTxFrame; 
@@ -79,9 +77,15 @@ generic module NoDispatchSlottedCsmaP(uint8_t superframeDirection)
 }
 implementation
 {
+  enum {
+    COORD_ROLE = (sfDirection == OUTGOING_SUPERFRAME),
+    DEVICE_ROLE = !COORD_ROLE,
+    RADIO_CLIENT_CFP = COORD_ROLE ? RADIO_CLIENT_COORDCFP : RADIO_CLIENT_DEVICECFP,
+  };  
+
   command error_t Reset.init() { return SUCCESS; }
 
-  async event void TokenTransferred.transferred() { }
+  async event void RadioToken.transferredFrom(uint8_t c) { call RadioToken.transferTo(RADIO_CLIENT_CFP); }
 
   command ieee154_status_t FrameTx.transmit(ieee154_txframe_t *frame) { return IEEE154_TRANSACTION_OVERFLOW; }
 
@@ -104,9 +108,9 @@ implementation
 
   event message_t* RadioRx.received(message_t* frame, const ieee154_timestamp_t *timestamp) { return frame; }
 
-  async command ieee154_status_t BroadcastTx.transmitNow(ieee154_txframe_t *frame) { }
+  async command ieee154_status_t BroadcastTx.transmitNow(ieee154_txframe_t *frame) { return IEEE154_TRANSACTION_OVERFLOW;}
 
-  event void Token.granted() { }
+  event void RadioToken.granted() { }
 
   command error_t WasRxEnabled.enable(){return FAIL;}
   command error_t WasRxEnabled.disable(){return FAIL;}
index 40929940da21bab688e936a58b69c54ad15cedf2..ae3a2124fe29def3f696b56bfcb1508147aa1d49 100644 (file)
@@ -44,6 +44,7 @@ module NoPromiscuousModeP
     interface SplitControl as PromiscuousMode;
     interface Get<bool> as PromiscuousModeGet;
     interface FrameRx;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
   } uses {
     interface Resource as Token;
     interface RadioRx as PromiscuousRx;
@@ -74,4 +75,5 @@ implementation
 
   default event void PromiscuousMode.startDone(error_t error){}
   default event void PromiscuousMode.stopDone(error_t error){}
+  async command token_requested_t IsRadioTokenRequested.getNow(){ return FALSE;}
 }
index a2591add4c2d74a70e3cfebf163a2ff4ccee5083..4bfaff48522e36bcf75ab8a39c9b031783f05d21 100644 (file)
@@ -44,6 +44,7 @@ module NoScanP
     interface Init;
     interface MLME_SCAN;
     interface MLME_BEACON_NOTIFY;
+    interface GetNow<token_requested_t> as IsRadioTokenRequested;
   }
   uses
   {
@@ -58,7 +59,7 @@ module NoScanP
     interface Timer<TSymbolIEEE802154> as ScanTimer;
     interface Pool<ieee154_txframe_t> as TxFramePool;
     interface Pool<ieee154_txcontrol_t> as TxControlPool;
-    interface Resource as Token;
+    interface TransferableResource as RadioToken;
     interface FrameUtility;
     interface Leds;
   }
@@ -83,9 +84,9 @@ implementation
     return IEEE154_TRANSACTION_OVERFLOW;
   }
 
-  event void Token.granted()
+  event void RadioToken.granted()
   {
-    call Token.release();
+    ASSERT(0);
   }
 
   event void EnergyDetection.done(error_t status, int8_t EnergyLevel){}
@@ -103,4 +104,6 @@ implementation
   event void ScanTimer.fired() { }
 
   async event void RadioOff.offDone() { }
+  async event void RadioToken.transferredFrom(uint8_t fromClient){ASSERT(0);}
+  async command token_requested_t IsRadioTokenRequested.getNow(){ return FALSE;}
 }
diff --git a/tos/lib/mac/tkn154/interfaces/private/ResourceTransfer.nc b/tos/lib/mac/tkn154/interfaces/private/ResourceTransfer.nc
deleted file mode 100644 (file)
index 812c6b9..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* 
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.  - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.  - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransfer
-{
-
-  /** 
-   * Transfers ownership of a resource to another client, which will in turn
-   * be signalled a ResourceTransferred.transferred() event. 
-   *
-   * When a resource that was transferred through this command is released, it
-   * is released on behalf of the "original" client, i.e. who was last
-   * signalled the Resource.granted() event and it then depends on the original
-   * queueing policy which component will be granted the resource next.
-   *
-   * @return SUCCESS If ownership has been transferred.<br> FAIL ownership has
-   * not been transferred, because the caller is not owner of the resource
-   */
-  async command error_t transfer(); 
-}
diff --git a/tos/lib/mac/tkn154/interfaces/private/ResourceTransferConnector.nc b/tos/lib/mac/tkn154/interfaces/private/ResourceTransferConnector.nc
deleted file mode 100644 (file)
index ec8c8ac..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* 
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.  - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.  - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferConnector 
-{
-  async command uint8_t getUserId();
-  async command void transfer();
-}
diff --git a/tos/lib/mac/tkn154/interfaces/private/ResourceTransferControl.nc b/tos/lib/mac/tkn154/interfaces/private/ResourceTransferControl.nc
deleted file mode 100644 (file)
index a7a82ea..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/* 
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.  - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.  - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferControl 
-{
-  async command error_t transfer(uint8_t fromClient, uint8_t toClient);
-}
diff --git a/tos/lib/mac/tkn154/interfaces/private/ResourceTransferred.nc b/tos/lib/mac/tkn154/interfaces/private/ResourceTransferred.nc
deleted file mode 100644 (file)
index 48f3650..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* 
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.  - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution.  - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferred 
-{
-
-  /** 
-   * Ownership of a resource is transferred, possibly overriding the default
-   * queueing policy. This event is similar to an async Resource.granted()
-   * event, initiated by the previous owner of the resource.
-   *
-   * @see ResourceTransfer interface
-   */
-  async event void transferred(); 
-}
diff --git a/tos/lib/mac/tkn154/interfaces/private/TransferableResource.nc b/tos/lib/mac/tkn154/interfaces/private/TransferableResource.nc
new file mode 100644 (file)
index 0000000..3aed6e5
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+ * "Copyright (c) 2005 Washington University in St. Louis.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY 
+ * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING 
+ * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON 
+ * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO 
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS."
+ */
+/*
+ * Copyright (c) 2004, Technische Universitat Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitat Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+  /** 
+   * This interface is the same as the standard <tt>Resource</tt> 
+   * interface, except that it has one new command <tt>transferTo()</tt> 
+   * and one new event <tt>transferred()</tt>, which allow to pass 
+   * the resource from one component to another.
+   *
+   * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+   */
+
+interface TransferableResource
+{
+  /**
+   * Request access to a shared resource. You must call release()
+   * when you are done with it.
+   *
+   * @return SUCCESS When a request has been accepted. The granted()
+   *                 event will be signaled once you have control of the
+   *                 resource.<br>
+   *         EBUSY You have already requested this resource and a
+   *               granted event is pending
+   */
+  async command error_t request();
+
+  /**
+  * Request immediate access to a shared resource. You must call release()
+  * when you are done with it.
+  *
+  * @return SUCCESS When a request has been accepted. <br>
+  *            FAIL The request cannot be fulfilled
+  */
+  async command error_t immediateRequest();
+
+  /**
+   * You are now in control of the resource.
+   */
+  event void granted();
+
+  /** 
+   * Transfers ownership of a resource to another client, which will in turn
+   * be signalled the <tt>transferred()</tt> event. This command may override 
+   * the default queueing policy.
+   *
+   * @param dstClient The identifier of the client to transfer the resource to.
+   *
+   * @return SUCCESS If ownership has been transferred; FAIL if ownership has
+   * not been transferred, because the caller is not owner of the resource or
+   * a client with the identifer <tt>dstClient</tt> is not present.
+   */   
+  async command error_t transferTo(uint8_t dstClient); 
+
+  /** 
+   * Another client transferred ownership of the resource to you by calling
+   * the <tt>transfer()</tt> command, i.e. you are now in control of the resource.
+   *
+   * @param srcClient The identifier of the client that transferred the resource to you.
+   */
+  async event void transferredFrom(uint8_t srcClient); 
+
+  /**
+  * Release a shared resource you previously acquired.  
+  *
+  * @return SUCCESS The resource has been released <br>
+  *         FAIL You tried to release but you are not the
+  *              owner of the resource 
+  *
+  * @note This command should never be called between putting in a request       
+  *       and waiting for a granted event.  Doing so will result in a
+  *       potential race condition.  There are ways to guarantee that no
+  *       race will occur, but they are clumsy and overly complicated.
+  *       Since it doesn't logically make since to be calling
+  *       <code>release</code> before receiving a <code>granted</code> event, 
+  *       we have opted to keep thing simple and warn you about the potential 
+  *       race.
+  */
+  async command error_t release();
+
+  /**
+   *  Check if the user of this interface is the current
+   *  owner of the Resource
+   *  @return TRUE  It is the owner <br>
+   *             FALSE It is not the owner
+   */
+  async command bool isOwner();
+}
index 5b76993f20e7912813b800c26bc118aaffd1a332..8dabee10e75fec78721650a86439a217fc89993a 100644 (file)
@@ -11,7 +11,7 @@
 #else
 typedef struct {
   uint8_t control;  // stores length (lower 7 bits), top bit -> promiscuous mode
-  uint8_t mhr[23];  // maximum header size without security
+  uint8_t mhr[MHR_MAX_LEN];  // maximum header size without security
 } ieee154_header_t;
 
 typedef struct {