interface Alarm<TSymbolIEEE802154,uint32_t> as BLEAlarm;
interface Alarm<TSymbolIEEE802154,uint32_t> as IndirectTxWaitAlarm;
interface Alarm<TSymbolIEEE802154,uint32_t> as BroadcastAlarm;
- interface Resource as Token;
- interface GetNow<bool> as IsTokenRequested;
- interface ResourceTransfer as TokenToCfp;
- interface ResourceTransferred as TokenTransferred;
+ interface TransferableResource as RadioToken;
interface SuperframeStructure;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
interface GetNow<bool> as IsRxEnableActive;
interface Get<ieee154_txframe_t*> as GetIndirectTxFrame;
interface Notify<bool> as RxEnableStateChange;
enum {
COORD_ROLE = (sfDirection == OUTGOING_SUPERFRAME),
DEVICE_ROLE = !COORD_ROLE,
+ RADIO_CLIENT_CFP = COORD_ROLE ? RADIO_CLIENT_COORDCFP : RADIO_CLIENT_DEVICECFP,
};
/* state / frame management */
return SUCCESS;
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClient)
{
// we got the token, i.e. CAP has just started
uint32_t capDuration = (uint32_t) call SuperframeStructure.numCapSlots() *
} else if (capDuration < guardTime) {
// CAP is too short to do anything practical
dbg_serial("DispatchSlottedCsmaP", "CAP too short!\n");
- call TokenToCfp.transfer();
+ call RadioToken.transferTo(RADIO_CLIENT_CFP);
return;
} else {
capDuration -= guardTime;
atomic {
// long atomics are bad... but in this block, once the/ current state has
// been determined only one branch will/ be taken (there are no loops)
- if (m_lock || !call Token.isOwner())
+ if (m_lock || !call RadioToken.isOwner())
return;
m_lock = TRUE; // lock
capDuration = (uint32_t) call SuperframeStructure.numCapSlots() *
m_lock = FALSE; // unlock
dbg_flush_state();
dbg_serial("DispatchSlottedCsmaP", "Handing over to CFP.\n");
- call TokenToCfp.transfer();
+ call RadioToken.transferTo(RADIO_CLIENT_CFP);
return;
} else
next = SWITCH_OFF;
}
// Check 4: is some other operation (like MLME-SCAN or MLME-RESET) pending?
- else if (call IsTokenRequested.getNow()) {
+ else if (call IsRadioTokenRequested.getNow()) {
dbg_push_state(4);
if (call RadioOff.isOff()) {
stopAllAlarms(); // may still fire, but is locked through isOwner()
// nothing more to do... just release the Token
m_lock = FALSE; // unlock
dbg_serial("DispatchSlottedCsmaP", "Token requested: Handing over to CFP.\n");
- call TokenToCfp.transfer();
+ call RadioToken.release();
return;
} else
next = SWITCH_OFF;
else {
dbg_push_state(8);
next = trySwitchOff();
- if (next == DO_NOTHING && (DEVICE_ROLE && capDuration == 0)) {
- // nothing more to do... just release the Token
- stopAllAlarms(); // may still fire, but is locked through isOwner()
- m_lock = FALSE; // unlock
- dbg_serial("DispatchSlottedCsmaP", "Releasing token\n");
- call Token.release();
- return;
- }
}
// if there is nothing to do, then we must clear the lock
// only once per CAP (max. one broadcast is allowed after a beacon
// transmission)
atomic {
- if (!call Token.isOwner() && m_bcastFrame == NULL) {
+ if (!call RadioToken.isOwner() && m_bcastFrame == NULL) {
m_bcastFrame = frame;
return IEEE154_SUCCESS;
} else {
signal WasRxEnabled.notify(TRUE);
}
- event void Token.granted()
+ event void RadioToken.granted()
{
ASSERT(0); // should never happen
}