X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Frf230%2FLowPowerListeningLayerP.nc;h=ef4bac568622da67001c384b7a0f47ca8256962b;hb=adf1de6c009d13b7b52e68535c63b28f59c97400;hp=502820d0e2d38faeeb02534b8aa05daf3b513768;hpb=ba0b31a23ea2d356a91d698e5d11f0d55e5ddbe1;p=tinyos-2.x.git diff --git a/tos/chips/rf230/LowPowerListeningLayerP.nc b/tos/chips/rf230/LowPowerListeningLayerP.nc index 502820d0..ef4bac56 100644 --- a/tos/chips/rf230/LowPowerListeningLayerP.nc +++ b/tos/chips/rf230/LowPowerListeningLayerP.nc @@ -253,7 +253,7 @@ implementation event void Timer.fired() { - ASSERT( state == LISTEN || state == SLEEP || state == SEND_SUBSEND|| state == SEND_SUBSEND_DONE ); + ASSERT( state == LISTEN || state == SLEEP || state == SEND_SUBSEND || state == SEND_SUBSEND_DONE ); if( state == LISTEN ) state = SLEEP_SUBSTOP; @@ -267,16 +267,6 @@ implementation post transition(); } - void sleepIntervalChanged() - { - if( (state == LISTEN && sleepInterval == 0) || state == SLEEP ) - { - call Timer.stop(); - --state; - post transition(); - } - } - event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) { if( state == SLEEP_SUBSTOP ) @@ -296,11 +286,11 @@ implementation post transition(); } - if( state == LISTEN_SUBSTART || state == SLEEP_TIMER || state == LISTEN ) + if( state == LISTEN_SUBSTART || state == SLEEP_TIMER || state == SLEEP ) state = SEND_SUBSTART; else if( state == LISTEN_SUBSTART_DONE ) state = SEND_SUBSTART_DONE; - else if( state == LISTEN_TIMER || state == SLEEP_SUBSTOP|| state == LISTEN ) + else if( state == LISTEN_TIMER || state == SLEEP_SUBSTOP || state == LISTEN ) state = SEND_TIMER; else return EBUSY; @@ -317,12 +307,19 @@ implementation if( state == SEND_SUBSEND ) { call Timer.stop(); - state = LISTEN_TIMER; + state = SEND_DONE; + txError = ECANCEL; post transition(); - // TODO: ask if sendDone should be called after a succesfull cancel return SUCCESS; } + else if( state == SEND_SUBSEND_DONE ) + { + // we stop sending the message even if SubSend.cancel was not succesfull + state = SEND_SUBSEND_DONE_LAST; + + return call SubSend.cancel(txMsg); + } else return FAIL; } @@ -389,7 +386,13 @@ implementation interval = MAX_SLEEP; sleepInterval = interval; - sleepIntervalChanged(); + + if( (state == LISTEN && sleepInterval == 0) || state == SLEEP ) + { + call Timer.stop(); + --state; + post transition(); + } } command uint16_t LowPowerListening.getLocalSleepInterval() @@ -421,23 +424,20 @@ implementation command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg) { if( ! call PacketSleepInterval.isSet(msg) ) - return 0; + return sleepInterval; return call PacketSleepInterval.get(msg); } command void LowPowerListening.setRxDutyCycle(message_t *msg, uint16_t dutyCycle) { - call PacketSleepInterval.set(msg, + call LowPowerListening.setRxSleepInterval(msg, call LowPowerListening.dutyCycleToSleepInterval(dutyCycle)); } command uint16_t LowPowerListening.getRxDutyCycle(message_t *msg) { - if( ! call PacketSleepInterval.isSet(msg) ) - return 10000; - return call LowPowerListening.sleepIntervalToDutyCycle( - call PacketSleepInterval.get(msg)); + call LowPowerListening.getRxSleepInterval(msg)); } }