X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Frf230%2FMessageBufferLayerP.nc;h=374edaadbeaee492d79c197ef8045a13c36498e2;hb=60f8c4ec4b792c6a99d5ef66ee413e8712a10a1e;hp=76ef080b397e911e3f613a3df5c6373f5c79a93a;hpb=c200f0d798d7f9631eabfb79008615936a52b5af;p=tinyos-2.x.git diff --git a/tos/chips/rf230/MessageBufferLayerP.nc b/tos/chips/rf230/MessageBufferLayerP.nc index 76ef080b..374edaad 100644 --- a/tos/chips/rf230/MessageBufferLayerP.nc +++ b/tos/chips/rf230/MessageBufferLayerP.nc @@ -33,6 +33,7 @@ module MessageBufferLayerP interface Send; interface Receive; + interface RadioChannel; } uses { @@ -58,6 +59,7 @@ implementation STATE_TX_DONE = 3, STATE_TURN_ON = 4, STATE_TURN_OFF = 5, + STATE_CHANNEL = 6, }; command error_t SplitControl.start() @@ -98,19 +100,47 @@ implementation return error; } + command error_t RadioChannel.setChannel(uint8_t channel) + { + error_t error; + + call Tasklet.suspend(); + + if( state != STATE_READY ) + error = EBUSY; + else + error = call RadioState.setChannel(channel); + + if( error == SUCCESS ) + state = STATE_CHANNEL; + + call Tasklet.resume(); + + return error; + } + + command uint8_t RadioChannel.getChannel() + { + return call RadioState.getChannel(); + } + task void stateDoneTask() { uint8_t s; s = state; - if( s == STATE_TURN_ON || s == STATE_TURN_OFF ) - state = STATE_READY; + // change the state before so we can be reentered from the event + state = STATE_READY; if( s == STATE_TURN_ON ) signal SplitControl.startDone(SUCCESS); - else + else if( s == STATE_TURN_OFF ) signal SplitControl.stopDone(SUCCESS); + else if( s == STATE_CHANNEL ) + signal RadioChannel.setChannelDone(); + else // not our event, ignore it + state = s; } tasklet_async event void RadioState.done() @@ -126,6 +156,10 @@ implementation { } + default event void RadioChannel.setChannelDone() + { + } + /*----------------- Send -----------------*/ message_t* txMsg; @@ -257,7 +291,7 @@ implementation { bool notFull; - // this prevents undelivered messages to be acknowledged + // this prevents undeliverable messages to be acknowledged atomic notFull = receiveQueueSize < RECEIVE_QUEUE_SIZE; return notFull;