provides
{
interface SplitControl;
- interface Send;
- interface Receive;
+ interface BareSend as Send;
+ interface BareReceive as Receive;
+ interface RadioPacket;
interface LowPowerListening;
}
uses
{
interface SplitControl as SubControl;
- interface Send as SubSend;
- interface Receive as SubReceive;
+ interface BareSend as SubSend;
+ interface BareReceive as SubReceive;
+ interface RadioPacket as SubPacket;
interface PacketAcknowledgements;
interface LowPowerListeningConfig as Config;
uint16_t sleepInterval;
message_t* txMsg;
- uint8_t txLen;
error_t txError;
/*----------------- state machine -----------------*/
}
else if( state == SEND_SUBSEND)
{
- txError = call SubSend.send(txMsg, txLen);
+ txError = call SubSend.send(txMsg);
if( txError == SUCCESS )
state = SEND_SUBSEND_DONE;
post transition();
}
- event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len)
+ event message_t* SubReceive.receive(message_t* msg)
{
if( state == SLEEP_SUBSTOP )
state = LISTEN;
if( state == LISTEN && sleepInterval > 0 )
call Timer.startOneShot(AFTER_RECEIVE);
- return signal Receive.receive(msg, payload, len);
+ return signal Receive.receive(msg);
}
- command error_t Send.send(message_t* msg, uint8_t len)
+ command error_t Send.send(message_t* msg)
{
if( state == LISTEN || state == SLEEP )
{
return EBUSY;
txMsg = msg;
- txLen = len;
txError = FAIL;
return SUCCESS;
post transition();
}
- command uint8_t Send.maxPayloadLength()
- {
- return call SubSend.maxPayloadLength();
- }
+/*----------------- LowPowerListening -----------------*/
- command void* Send.getPayload(message_t* msg, uint8_t len)
+ lpl_metadata_t* getMeta(message_t* msg)
{
- return call SubSend.getPayload(msg, len);
+ return ((void*)msg) + sizeof(message_t) - call RadioPacket.metadataLength(msg);
}
-/*----------------- LowPowerListening -----------------*/
-
command uint16_t LowPowerListening.dutyCycleToSleepInterval(uint16_t dutyCycle)
{
if( dutyCycle >= 10000 )
else if( interval > MAX_SLEEP )
interval = MAX_SLEEP;
- (call Config.metadata(msg))->sleepint = interval;
+ getMeta(msg)->sleepint = interval;
}
command uint16_t LowPowerListening.getRxSleepInterval(message_t *msg)
{
- uint16_t sleepint = (call Config.metadata(msg))->sleepint;
-
- return sleepint != 0 ? sleepint : sleepInterval;
+ return getMeta(msg)->sleepint;
}
command void LowPowerListening.setRxDutyCycle(message_t *msg, uint16_t dutyCycle)
call LowPowerListening.getRxSleepInterval(msg));
}
- async event void Config.clear(message_t* msg)
+/*----------------- RadioPacket -----------------*/
+
+ async command uint8_t RadioPacket.headerLength(message_t* msg)
+ {
+ return call SubPacket.headerLength(msg);
+ }
+
+ async command uint8_t RadioPacket.payloadLength(message_t* msg)
+ {
+ return call SubPacket.payloadLength(msg);
+ }
+
+ async command void RadioPacket.setPayloadLength(message_t* msg, uint8_t length)
+ {
+ call SubPacket.setPayloadLength(msg, length);
+ }
+
+ async command uint8_t RadioPacket.maxPayloadLength()
+ {
+ return call SubPacket.maxPayloadLength();
+ }
+
+ async command uint8_t RadioPacket.metadataLength(message_t* msg)
+ {
+ return call SubPacket.metadataLength(msg) + sizeof(lpl_metadata_t);
+ }
+
+ async command void RadioPacket.clear(message_t* msg)
{
- (call Config.metadata(msg))->sleepint = 0;
+ getMeta(msg)->sleepint = 0;
+ call SubPacket.clear(msg);
}
}