]> oss.titaniummirror.com Git - tinyos-2.x.git/blobdiff - tos/lib/mac/tkn154/RxEnableP.nc
- moved promiscuous mode into separate component
[tinyos-2.x.git] / tos / lib / mac / tkn154 / RxEnableP.nc
index 6835bed8ae845b454253e3b6717c2967f086edde..b7dad3a8573d3a32994d536369032bea9d5baaa9 100644 (file)
@@ -41,18 +41,11 @@ module RxEnableP
   {
     interface Init;
     interface MLME_RX_ENABLE;
-    interface SplitControl as PromiscuousMode;
-    interface FrameRx;
-    interface Get<bool> as PromiscuousModeGet;
     interface GetNow<bool> as IsRxEnableActive; 
     interface Notify<bool> as RxEnableStateChange;
   }
   uses
   {
-    interface Resource as Token;
-    interface RadioRx as PromiscuousRx;
-    interface RadioOff;
-    interface Set<bool> as RadioPromiscuousMode;
     interface Ieee802154Debug as Debug;
     interface Timer<TSymbolIEEE802154> as RxEnableTimer;
     interface Get<bool> as IsBeaconEnabledPAN;
@@ -60,7 +53,7 @@ module RxEnableP
     interface GetNow<bool> as IsTrackingBeacons;
     interface GetNow<uint32_t> as IncomingSfStart; 
     interface GetNow<uint32_t> as IncomingBeaconInterval; 
-    interface Get<bool> as IsSendingBeacons;
+    interface GetNow<bool> as IsSendingBeacons;
     interface GetNow<uint32_t> as OutgoingSfStart; 
     interface GetNow<uint32_t> as OutgoingBeaconInterval; 
     interface Notify<bool> as WasRxEnabled;
@@ -69,12 +62,6 @@ module RxEnableP
 }
 implementation
 {
-  enum promiscuous_state {
-    S_IDLE,
-    S_STARTING,
-    S_STARTED,
-    S_STOPPING,
-  } m_promiscuousState;
 
   uint32_t m_rxOnDuration;
   uint32_t m_rxOnOffset;
@@ -82,9 +69,6 @@ implementation
   norace bool m_isRxEnabled;
   bool m_isRxEnableConfirmPending;
 
-  task void prepareDoneTask();
-  task void radioOffDoneTask();
-
   command error_t Init.init()
   {
     if (m_isRxEnableConfirmPending){
@@ -112,7 +96,7 @@ implementation
     if (RxOnTime > 0xFFFFFF || RxOnDuration > 0xFFFFFF)
       return IEEE154_INVALID_PARAMETER;
     if (call IsBeaconEnabledPAN.get()){
-      if (call IsSendingBeacons.get() && call IsMacPanCoordinator.get()){
+      if (call IsSendingBeacons.getNow() && call IsMacPanCoordinator.get()){
         // for OUTGOING SUPERFRAME
         lastBeaconTime = call OutgoingSfStart.getNow();
         beaconInterval = call OutgoingBeaconInterval.getNow();
@@ -181,94 +165,5 @@ implementation
 
   command error_t RxEnableStateChange.enable(){return FAIL;}
   command error_t RxEnableStateChange.disable(){return FAIL;}
-
-/* ----------------------- Promiscuous Mode ----------------------- */
-
-  command bool PromiscuousModeGet.get()
-  {
-    return (m_promiscuousState == S_STARTED);
-  }
-
-  command error_t PromiscuousMode.start()
-  {
-    if (m_promiscuousState != S_IDLE)
-      return FAIL;
-    m_promiscuousState = S_STARTING;
-    call Token.request();
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_REQUEST, m_promiscuousState, 0, 0);
-    call Debug.flush();
-    return SUCCESS;
-  }
-
-  event void Token.granted()
-  {
-    if (m_promiscuousState != S_STARTING){
-      call Token.release();
-      return;
-    }
-    call RadioPromiscuousMode.set(TRUE);
-    if (call PromiscuousRx.prepare() != IEEE154_SUCCESS){
-      m_promiscuousState = S_IDLE;
-      call Token.release();
-      call Debug.log(LEVEL_IMPORTANT, EnableRxP_RADIORX_ERROR, 0, 0, 0);
-      signal PromiscuousMode.startDone(FAIL);
-    }
-  }
-
-  async event void PromiscuousRx.prepareDone()
-  {
-    post prepareDoneTask();
-  }
-
-  task void prepareDoneTask()
-  {
-    if (m_promiscuousState != S_STARTING){
-      call Token.release();
-      return;
-    }    
-    m_promiscuousState = S_STARTED;
-    call PromiscuousRx.receive(NULL, 0);
-    signal PromiscuousMode.startDone(SUCCESS);
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_ON, m_promiscuousState, 0, 0);
-  }
-
-  event message_t* PromiscuousRx.received(message_t *frame, ieee154_reftime_t *timestamp)
-  {
-    if (m_promiscuousState == S_STARTED){
-      ((ieee154_header_t*) frame->header)->length |= FRAMECTL_PROMISCUOUS;
-      return signal FrameRx.received(frame);
-    } else
-      return frame;
-  }
-
-  command error_t PromiscuousMode.stop()
-  {
-    if (m_promiscuousState != S_STARTED)
-      return FAIL;
-    m_promiscuousState = S_STOPPING;
-    call RadioOff.off();
-    return SUCCESS;
-  }
-
-  async event void RadioOff.offDone()
-  {
-    post radioOffDoneTask();
-  }
-
-  task void radioOffDoneTask()
-  {
-    if (m_promiscuousState != S_STOPPING){
-      call Token.release();
-      return;
-    }
-    m_promiscuousState = S_IDLE;
-    call RadioPromiscuousMode.set(FALSE);
-    call Token.release();
-    signal PromiscuousMode.stopDone(SUCCESS);
-    call Debug.log(LEVEL_INFO, EnableRxP_PROMISCUOUS_OFF, m_promiscuousState, 0, 0);
-  }
-
-  default event void PromiscuousMode.startDone(error_t error){}
-  default event void PromiscuousMode.stopDone(error_t error){}
   default event void MLME_RX_ENABLE.confirm(ieee154_status_t status){}
 }