interface Send;
interface Receive;
+ interface RadioChannel;
}
uses
{
STATE_TX_DONE = 3,
STATE_TURN_ON = 4,
STATE_TURN_OFF = 5,
+ STATE_CHANNEL = 6,
};
command error_t SplitControl.start()
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;
- // change the state before so we can be reentered rom the event
- 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()
{
}
+ default event void RadioChannel.setChannelDone()
+ {
+ }
+
/*----------------- Send -----------------*/
message_t* txMsg;
{
bool notFull;
- // this prevents undelivered messages to be acknowledged
+ // this prevents undeliverable messages to be acknowledged
atomic notFull = receiveQueueSize < RECEIVE_QUEUE_SIZE;
return notFull;