uses {
interface Send as SubSend;
interface CC2420Transmit as Resend;
- interface RadioBackoff[am_id_t amId];
+ interface RadioBackoff;
interface Receive as SubReceive;
interface AMPacket;
interface SplitControl as SubControl;
bool dutyCycling;
/**
- * Radio State
+ * Radio Power State
*/
enum {
- S_OFF,
+ S_OFF, // off by default
+ S_TURNING_ON,
S_ON,
+ S_TURNING_OFF,
};
/**
return 0;
}
- return (DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle;
+ return ((uint32_t)DUTY_ON_TIME * (10000 - dutyCycle)) / dutyCycle;
}
/**
return 10000;
}
- return getActualDutyCycle((DUTY_ON_TIME * 10000)
+ return getActualDutyCycle(((uint32_t)DUTY_ON_TIME * 10000)
/ (sleepInterval + DUTY_ON_TIME));
}
return SUCCESS;
}
- return FAIL;
+ return EBUSY;
}
command error_t Send.cancel(message_t *msg) {
return call SubSend.maxPayloadLength();
}
- command void *Send.getPayload(message_t* msg) {
- return call SubSend.getPayload(msg);
+ command void *Send.getPayload(message_t* msg, uint8_t len) {
+ return call SubSend.getPayload(msg, len);
}
/***************** RadioBackoff Events ****************/
- async event void RadioBackoff.requestInitialBackoff[am_id_t amId](message_t *msg) {
+ async event void RadioBackoff.requestInitialBackoff(message_t *msg) {
if((call CC2420PacketBody.getMetadata(msg))->rxInterval
> ONE_MESSAGE) {
- call RadioBackoff.setInitialBackoff[amId]( call Random.rand16()
+ call RadioBackoff.setInitialBackoff( call Random.rand16()
% (0x4 * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
}
}
- async event void RadioBackoff.requestCongestionBackoff[am_id_t amId](message_t *msg) {
+ async event void RadioBackoff.requestCongestionBackoff(message_t *msg) {
if((call CC2420PacketBody.getMetadata(msg))->rxInterval
> ONE_MESSAGE) {
- call RadioBackoff.setCongestionBackoff[amId]( call Random.rand16()
+ call RadioBackoff.setCongestionBackoff( call Random.rand16()
% (0x3 * CC2420_BACKOFF_PERIOD) + CC2420_MIN_BACKOFF);
}
}
- async event void RadioBackoff.requestCca[am_id_t amId](message_t *msg) {
+ async event void RadioBackoff.requestCca(message_t *msg) {
}
- /***************** Receive Commands ***************/
- command void *Receive.getPayload(message_t* msg, uint8_t* len) {
- return call SubReceive.getPayload(msg, len);
- }
-
- command uint8_t Receive.payloadLength(message_t* msg) {
- return call SubReceive.payloadLength(msg);
- }
-
/***************** DutyCycle Events ***************/
/**
// just a little longer in case there is more than one lpl transmitter on
// the channel.
- if(call SendState.isIdle()) {
- startOffTimer();
- }
+ startOffTimer();
}
}
/***************** Timer Events ****************/
- event void OffTimer.fired() {
+ event void OffTimer.fired() {
/*
* Only stop the radio if the radio is supposed to be off permanently
* or if the duty cycle is on and our sleep interval is not 0
*/
if(call SplitControlState.getState() == S_OFF
|| (call PowerCycle.getSleepInterval() > 0
- && call SplitControlState.getState() == S_ON
+ && call SplitControlState.getState() != S_OFF
&& call SendState.getState() == S_LPL_NOT_SENDING)) {
post stopRadio();
}