From dbddb4bea6c87c2b0f7b32f03e181408775446bb Mon Sep 17 00:00:00 2001 From: janhauer Date: Mon, 4 May 2009 09:40:36 +0000 Subject: [PATCH] Now supporting PIB attribute "macRxOnWhenIdle" --- tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc | 15 ++++++++++----- tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc | 13 +++++++++---- tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc | 2 ++ tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc | 1 + .../mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc | 2 ++ 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc b/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc index eccccc19..7709ae8f 100644 --- a/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc +++ b/tos/lib/mac/tkn154/DispatchSlottedCsmaP.nc @@ -80,6 +80,7 @@ generic module DispatchSlottedCsmaP(uint8_t sfDirection) interface Get as GetIndirectTxFrame; interface Notify as RxEnableStateChange; interface GetNow as IsTrackingBeacons; + interface Notify as PIBUpdateMacRxOnWhenIdle; interface FrameUtility; interface SlottedCsmaCa; interface RadioRx; @@ -121,6 +122,7 @@ implementation norace ieee154_txframe_t *m_bcastFrame; norace ieee154_txframe_t *m_lastFrame; norace uint16_t m_remainingBackoff; + ieee154_macRxOnWhenIdle_t macRxOnWhenIdle; /* variables for the slotted CSMA-CA */ norace ieee154_csma_t m_csma; @@ -406,7 +408,7 @@ implementation else if (call SuperframeStructure.battLifeExtDuration() > 0 && call TimeCalc.hasExpired(call SuperframeStructure.sfStartTime(), call SuperframeStructure.battLifeExtDuration()) && - !call IsRxEnableActive.getNow()) { + !call IsRxEnableActive.getNow() && !macRxOnWhenIdle) { dbg_push_state(5); next = trySwitchOff(); } @@ -418,13 +420,12 @@ implementation } // Check 7: should we be in receive mode? - else if (COORD_ROLE || call IsRxEnableActive.getNow()) { + else if (COORD_ROLE || call IsRxEnableActive.getNow() || macRxOnWhenIdle) { dbg_push_state(7); next = tryReceive(NO_ALARM); if (next == DO_NOTHING) { - // this means there is an active MLME_RX_ENABLE.request - // and the radio was just switched to Rx mode - signal - // a notify event to inform the respective component + // if there was an active MLME_RX_ENABLE.request then we'll + // inform the next higher layer that radio is now in Rx mode post wasRxEnabledTask(); } } @@ -524,6 +525,10 @@ implementation async event void BLEAlarm.fired() { updateState();} event void RxEnableStateChange.notify(bool whatever) { updateState();} async event void BroadcastAlarm.fired() { m_broadcastRxPending = FALSE; updateState();} + event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) { + atomic macRxOnWhenIdle = *((ieee154_macRxOnWhenIdle_t*) val); + updateState(); + } async event void IndirectTxWaitAlarm.fired() { diff --git a/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc b/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc index 53ebe948..f579f71f 100644 --- a/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc +++ b/tos/lib/mac/tkn154/DispatchUnslottedCsmaP.nc @@ -67,6 +67,7 @@ module DispatchUnslottedCsmaP interface Set as SetMacPanCoordinator; interface Get as GetIndirectTxFrame; interface Notify as RxEnableStateChange; + interface Notify as PIBUpdateMacRxOnWhenIdle; interface FrameUtility; interface UnslottedCsmaCa; interface RadioRx; @@ -96,6 +97,7 @@ implementation norace bool m_resume; norace ieee154_txframe_t *m_currentFrame; norace ieee154_txframe_t *m_lastFrame; + norace ieee154_macRxOnWhenIdle_t macRxOnWhenIdle; /* variables for the unslotted CSMA-CA */ norace ieee154_csma_t m_csma; @@ -275,12 +277,11 @@ implementation } // Check 4: should we be in receive mode? - else if (call IsRxEnableActive.getNow()) { + else if (call IsRxEnableActive.getNow() || macRxOnWhenIdle) { next = tryReceive(FALSE); if (next == DO_NOTHING) { - // this means there is an active MLME_RX_ENABLE.request - // and the radio was just switched to Rx mode - signal - // a notify event to inform the next higher layer + // if there was an active MLME_RX_ENABLE.request then we'll + // inform the next higher layer that radio is now in Rx mode post wasRxEnabledTask(); } } @@ -362,6 +363,10 @@ implementation else updateState(); } + event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) { + atomic macRxOnWhenIdle = *((ieee154_macRxOnWhenIdle_t*) val); + signal RxEnableStateChange.notify(TRUE); + } event void IndirectTxWaitTimer.fired() { diff --git a/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc b/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc index a04bfea8..62633314 100644 --- a/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc +++ b/tos/lib/mac/tkn154/TKN154BeaconEnabledP.nc @@ -413,6 +413,7 @@ implementation DeviceCap.GetIndirectTxFrame -> IndirectTxP; DeviceCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange; DeviceCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons; + DeviceCap.PIBUpdateMacRxOnWhenIdle -> PibP.PIBUpdate[IEEE154_macRxOnWhenIdle]; DeviceCap.FrameUtility -> PibP; DeviceCap.SlottedCsmaCa -> DeviceCapRadioClient; DeviceCap.RadioRx -> DeviceCapRadioClient; @@ -439,6 +440,7 @@ implementation CoordCap.GetIndirectTxFrame -> IndirectTxP; CoordCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange; CoordCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons; + CoordCap.PIBUpdateMacRxOnWhenIdle -> PibP.PIBUpdate[IEEE154_macRxOnWhenIdle]; CoordCap.FrameUtility -> PibP; CoordCap.SlottedCsmaCa -> CoordCapRadioClient; CoordCap.RadioRx -> CoordCapRadioClient; diff --git a/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc b/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc index e5b79176..fa2d24d2 100644 --- a/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc +++ b/tos/lib/mac/tkn154/TKN154NonBeaconEnabledP.nc @@ -293,6 +293,7 @@ implementation DispatchP.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested; DispatchP.GetIndirectTxFrame -> IndirectTxP; DispatchP.RxEnableStateChange -> RxEnableP.RxEnableStateChange; + DispatchP.PIBUpdateMacRxOnWhenIdle -> PibP.PIBUpdate[IEEE154_macRxOnWhenIdle]; DispatchP.FrameUtility -> PibP; DispatchP.UnslottedCsmaCa -> DispatchRadioClient; DispatchP.RadioRx -> DispatchRadioClient; diff --git a/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc b/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc index b61259ec..b664b3f9 100644 --- a/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc +++ b/tos/lib/mac/tkn154/dummies/NoDispatchSlottedCsmaP.nc @@ -62,6 +62,7 @@ generic module NoDispatchSlottedCsmaP(uint8_t sfDirection) interface Get as GetIndirectTxFrame; interface Notify as RxEnableStateChange; interface GetNow as IsTrackingBeacons; + interface Notify as PIBUpdateMacRxOnWhenIdle; interface FrameUtility; interface SlottedCsmaCa; interface RadioRx; @@ -114,4 +115,5 @@ implementation command error_t WasRxEnabled.enable(){return FAIL;} command error_t WasRxEnabled.disable(){return FAIL;} + event void PIBUpdateMacRxOnWhenIdle.notify( const void* val ) {} } -- 2.39.2