interface Alarm<TSymbolIEEE802154,uint32_t> as TrackAlarm;
interface RadioRx as BeaconRx;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface DataRequest;
interface FrameRx as CoordRealignmentRx;
interface Resource as Token;
+ interface GetNow<bool> as IsTokenRequested;
interface ResourceTransferred as TokenTransferred;
interface ResourceTransfer as TokenToCap;
interface TimeCalc;
currentChannelBit <<= logicalChannel;
if (!(currentChannelBit & supportedChannels) || (call MLME_GET.macPANId() == 0xFFFF) ||
- (channelPage != IEEE154_SUPPORTED_CHANNELPAGE) || !call IsBeaconEnabledPAN.get())
+ (channelPage != IEEE154_SUPPORTED_CHANNELPAGE) || !call IsBeaconEnabledPAN.getNow())
return IEEE154_INVALID_PARAMETER;
call Debug.log(LEVEL_INFO,SyncP_REQUEST, logicalChannel, channelPage, trackBeacon);
m_internalRequest = FALSE;
m_updatePending = TRUE;
call Debug.log(LEVEL_INFO,SyncP_RESOURCE_REQUEST, 0, 0, 0);
- call Token.request();
+ atomic {
+ // if we are tracking then we'll get the Token automatically,
+ // otherwise request it now
+ if (!m_tracking && !call Token.isOwner())
+ call Token.request();
+ }
}
call Debug.flush();
return IEEE154_SUCCESS;
event void Token.granted()
{
- call Debug.flush();
call Debug.log(LEVEL_INFO,SyncP_GOT_RESOURCE, m_lastBeaconRxTime+m_beaconInterval,
m_beaconInterval, (m_updatePending<<1)+m_tracking);
if (m_updatePending){
call MLME_GET.macPANId(), m_updateLogicalChannel);
}
getNextBeacon();
+ call Debug.flush();
}
void getNextBeacon()
// we have received at least one previous beacon
m_state = S_PREPARE;
if (!m_tracking){
+ // nothing to do, just give up the token
call Debug.log(LEVEL_INFO,SyncP_RELEASE_RESOURCE, 0, 0, 0);
call Token.release();
return;
}
- while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon
+ while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)){ // missed a beacon!
missed = TRUE;
call Debug.log(LEVEL_INFO,SyncP_BEACON_MISSED_1, m_lastBeaconRxTime, m_dt, missed);
m_dt += m_beaconInterval;
async event void TokenTransferred.transferred()
{
- if (m_updatePending)
+ if (call IsTokenRequested.getNow()){
+ // some other component needs the token - we give it up for now,
+ // but make another request to get it back later
+ call Token.request();
+ call Token.release();
+ } else if (m_updatePending)
post signalGrantedTask();
else
getNextBeacon();
task void processBeaconTask()
{
-
// valid beacon timestamp is pre-condition for slotted CSMA-CA
if (m_beaconSwapBufferReady || !call Frame.isTimestampValid(m_beaconBufferPtr)){
// missed a beacon!
+ m_sfSlotDuration = 0; // CAP len will be 0
m_numBeaconsLost++;
m_dt += m_beaconInterval;
call Debug.log(LEVEL_IMPORTANT, SyncP_BEACON_MISSED_3,m_numBeaconsLost,0,m_lastBeaconRxTime);
if (m_stopTracking){
m_tracking = FALSE;
call Debug.log(LEVEL_INFO,SyncP_RELEASE_RESOURCE, 0, 0, 0);
+ if (m_updatePending) // there is already a new request pending...
+ call Token.request();
call Token.release();
} else {
- error_t req = call Token.request();
- call Debug.log(LEVEL_INFO,SyncP_TRANSFER_RESOURCE, req, 0, 0);
- call TokenToCap.transfer();
+ call Debug.log(LEVEL_INFO,SyncP_TRANSFER_RESOURCE, 0, 0, 0);
+ call TokenToCap.transfer(); // borrow Token to CAP/CFP module, we'll get it back afterwards
}
if (pendAddrSpec & PENDING_ADDRESS_SHORT_MASK)
interface Alarm<TSymbolIEEE802154,uint32_t> as BeaconTxAlarm;
interface Timer<TSymbolIEEE802154> as BeaconPayloadUpdateTimer;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface RadioTx as BeaconTx;
interface MLME_GET;
interface MLME_SET;
interface Resource as Token;
interface ResourceTransferred as TokenTransferred;
interface ResourceTransfer as TokenToBroadcast;
+ interface GetNow<bool> as IsTokenRequested;
interface FrameTx as RealignmentBeaconEnabledTx;
interface FrameTx as RealignmentNonBeaconEnabledTx;
interface FrameRx as BeaconRequestRx;
status = IEEE154_INVALID_PARAMETER;
else if (m_requests & (REQUEST_CONFIRM_PENDING | REQUEST_UPDATE_SF))
status = IEEE154_TRANSACTION_OVERFLOW;
- else if ((call IsBeaconEnabledPAN.get() && beaconOrder > 14) ||
- (!call IsBeaconEnabledPAN.get() && beaconOrder < 15))
+ else if ((call IsBeaconEnabledPAN.getNow() && beaconOrder == 15) ||
+ (!call IsBeaconEnabledPAN.getNow() && beaconOrder < 15))
status = IEEE154_INVALID_PARAMETER;
else {
// new configuration *will* be put in operation
if (coordRealignment)
m_requests |= REQUEST_REALIGNMENT;
if (m_beaconOrder == 15) // only request token if we're not already transmitting beacons
- call Token.request();
+ call Token.request(); // otherwise we'll get it eventually and update the superframe then
}
return status;
}
async event void TokenTransferred.transferred()
{
- post grantedTask();
+ if (call IsTokenRequested.getNow()){
+ // some other component needs the token - we give it up for now,
+ // but make another request to get it back later
+ call Token.request();
+ call Token.release();
+ } else
+ post grantedTask();
}
async event void RadioOff.offDone()
post grantedTask();
call Debug.log(LEVEL_CRITICAL, StartP_OWNER_TOO_FAST, 0, 0, 0);
return;
- } else if (m_beaconOrder > 14){
+ } else if (m_beaconOrder == 15){
call Token.release();
} else {
atomic {
m_BLELen += m_battLifeExtPeriods;
} else
m_BLELen = 0;
- call Token.request(); // register another request, before ...
- call TokenToBroadcast.transfer(); // ... we let Broadcast module take over
+ call TokenToBroadcast.transfer(); // borrow Token to Broadcast/CAP/CFP module, we'll get it back afterwards
post txDoneTask();
}
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 ResourceRequested as TokenRequested;
- interface GetNow<bool> as IsTokenRequested;
interface GetNow<uint32_t> as CapStart;
interface GetNow<ieee154_reftime_t*> as CapStartRefTime;
interface GetNow<uint32_t> as CapLen;
interface RadioTx;
interface RadioRx;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface MLME_GET;
interface MLME_SET;
interface Ieee802154Debug as Debug;
norace bool m_indirectTxPending = FALSE;
norace bool m_broadcastRxPending;
norace ieee154_macMaxFrameTotalWaitTime_t m_macMaxFrameTotalWaitTime;
- norace bool m_isBeaconEnabledPAN;
uint16_t generateRandomBackoff(uint8_t BE);
void stopAllAlarms();
command error_t Reset.init()
{
- if (call Token.isOwner()){
- call Leds.led0On(); // internal error
- return FAIL;
- }
if (m_currentFrame)
signal FrameTx.transmitDone(m_currentFrame, IEEE154_TRANSACTION_OVERFLOW);
if (m_lastFrame)
if (m_bcastFrame)
signalTxBroadcastDone(m_bcastFrame, IEEE154_TRANSACTION_OVERFLOW);
m_currentFrame = m_lastFrame = m_bcastFrame = NULL;
- m_macMaxFrameTotalWaitTime = call MLME_GET.macMaxFrameTotalWaitTime();
- m_isBeaconEnabledPAN = call IsBeaconEnabledPAN.get();
stopAllAlarms();
return SUCCESS;
}
{
// we got the token, i.e. CAP has just started
uint32_t actualCapLen = call CapLen.getNow();
- if (m_isBeaconEnabledPAN && (DEVICE_ROLE && !call IsTrackingBeacons.getNow())){
- // rare case: we're on a beacon-enabled PAN, not tracking beacons, searched
- // and didn't find a beacon for aBaseSuperframeDuration*(2n+1) symbols
+ if (!call IsBeaconEnabledPAN.getNow()){
+ call Leds.led0On(); // internal error!
+ call TokenToCfp.transfer();
+ call Debug.log(LEVEL_IMPORTANT, CapP_INTERNAL_ERROR, 0,0,0);
+ } else if (DEVICE_ROLE && actualCapLen == 0){
+ // very rare case:
+ // this can only happen, if we're on a beacon-enabled PAN, not tracking beacons,
+ // and searched but didn't find a beacon for aBaseSuperframeDuration*(2n+1) symbols
// -> transmit current frame using unslotted CSMA-CA
m_numCCA = 1;
+ updateState();
+ return;
} else if (actualCapLen < IEEE154_RADIO_GUARD_TIME){
call Debug.log(LEVEL_IMPORTANT, CapP_TOO_SHORT, superframeDirection, actualCapLen, IEEE154_RADIO_GUARD_TIME);
call TokenToCfp.transfer();
return IEEE154_TRANSACTION_OVERFLOW;
else {
setCurrentFrame(frame);
- if (!m_isBeaconEnabledPAN){
+ if (!call IsBeaconEnabledPAN.getNow()){
call Token.request(); // prepare for unslotted CSMA-CA
} else {
// a beacon must be found before transmitting in a beacon-enabled PAN
if (call MLME_GET.macBattLifeExt() && m_macMinBE > 2)
m_macMinBE = 2;
m_BE = m_macMinBE;
- if (m_isBeaconEnabledPAN)
+ if (call IsBeaconEnabledPAN.getNow())
m_numCCA = 2;
else
m_numCCA = 1;
m_lock = TRUE; // lock
// Check 1: for beacon-enabled PANs, has the CAP finished?
- if (m_isBeaconEnabledPAN
+ if (call IsBeaconEnabledPAN.getNow()
&& (COORD_ROLE || call IsTrackingBeacons.getNow()) // FALSE only if device could't find a beacon
&& (call TimeCalc.hasExpired(call CapStart.getNow(), call CapLen.getNow()-IEEE154_RADIO_GUARD_TIME) ||
!call CapEndAlarm.isRunning())){
}
// Check 4: is some other operation (like MLME-SCAN or MLME-RESET) pending?
- else if (call IsTokenRequested.getNow()) {
+ else if (call IsTokenRequested.getNow() && call IsBeaconEnabledPAN.getNow()) {
if (call RadioOff.isOff()) {
- stopAllAlarms(); // may still fire, locked through isOwner()
- call Token.release();
- next = DO_NOTHING;
+ stopAllAlarms(); // may still fire, but is locked through isOwner()
+ // nothing more to do... just release the Token
+ m_lock = FALSE; // unlock
+ call TokenToCfp.transfer();
+ return;
} else
next = SWITCH_OFF;
}
// Check 8: just make sure the radio is switched off
else {
next = trySwitchOff();
- if (next == DO_NOTHING && (!m_isBeaconEnabledPAN || (DEVICE_ROLE && !call IsTrackingBeacons.getNow()))){
+ if (next == DO_NOTHING &&
+ (!call IsBeaconEnabledPAN.getNow() || (DEVICE_ROLE && call CapLen.getNow() == 0))){
// nothing more to do... just release the Token
+ stopAllAlarms(); // may still fire, but is locked through isOwner()
m_lock = FALSE; // unlock
- call TokenToCfp.transfer();
+ call Token.release();
return;
}
}
event void Token.granted()
{
- // will not happen
- }
-
- task void tokenRequestedTask()
- {
- signal TokenRequested.requested();
- }
-
- async event void TokenRequested.requested()
- {
- // TODO: this event can be generated by the BeaconTransmitP or
- // BeaconSynchronizeP component - in this case the Token should
- // probably not be released!
- atomic {
- if (call Token.isOwner()){
- if (!m_lock && !(DEVICE_ROLE && m_indirectTxPending) && !(COORD_ROLE && m_bcastFrame))
- call Token.release();
- else
- post tokenRequestedTask();
- }
- }
+ // the current frame should be transmitted using unslotted CSMA-CA
+ updateState();
}
- async event void TokenRequested.immediateRequested() {}
-
default event void FrameTx.transmitDone(ieee154_txframe_t *data, ieee154_status_t status){}
default event message_t* FrameRx.received[uint8_t client](message_t* data){return data;}
default async command bool IsRxEnableActive.getNow(){return FALSE;}
interface Set<ieee154_macBeaconTxTime_t> as SetMacBeaconTxTime;
interface Set<ieee154_macPanCoordinator_t> as SetMacPanCoordinator;
interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface FrameUtility;
interface IEEE154Frame as Frame;
interface IEEE154BeaconFrame as BeaconFrame;
ieee154_PIB_t m_pib;
uint8_t m_numResetClientPending;
bool m_setDefaultPIB;
- uint8_t m_panType;
+ norace uint8_t m_panType;
+ uint8_t m_updatePANType;
uint8_t m_resetSpin;
#ifdef IEEE154_EXTENDED_ADDRESS
if (call PromiscuousModeGet.get())
return IEEE154_TRANSACTION_OVERFLOW; // must first cancel promiscuous mode!
m_setDefaultPIB = SetDefaultPIB;
- m_panType = PANType;
+ m_updatePANType = PANType;
if (!call Token.isOwner())
call Token.request();
return IEEE154_SUCCESS;
event void RadioControl.stopDone(error_t error)
{
- call CapReset.init(); // resets the CAP component(s)
- call CapQueueReset.init(); // resets the CAP queue component(s)
+ m_panType = m_updatePANType;
+ call CapReset.init(); // resets the CAP component(s), spool out frames
+ call CapQueueReset.init(); // resets the CAP queue component(s), spool out frames
call MacReset.init(); // resets the remaining components
m_resetSpin = 5;
post resetSpinTask();
return dest == m_pib.macCoordExtendedAddress;
}
- command bool IsBeaconEnabledPAN.get()
+ async command bool IsBeaconEnabledPAN.getNow()
{
return (m_panType == BEACON_ENABLED_PAN);
}
{
interface Ieee802154Debug as Debug;
interface Timer<TSymbolIEEE802154> as RxEnableTimer;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
interface GetNow<bool> as IsTrackingBeacons;
interface GetNow<uint32_t> as IncomingSfStart;
return IEEE154_TRANSACTION_OVERFLOW;
if (RxOnTime > 0xFFFFFF || RxOnDuration > 0xFFFFFF)
return IEEE154_INVALID_PARAMETER;
- if (call IsBeaconEnabledPAN.get()){
+ if (call IsBeaconEnabledPAN.getNow()){
if (call IsSendingBeacons.getNow() && call IsMacPanCoordinator.get()){
// for OUTGOING SUPERFRAME
lastBeaconTime = call OutgoingSfStart.getNow();
uint8_t state = RES_IDLE;
norace uint8_t resId = NO_RES;
norace uint8_t reqResId;
- norace uint8_t numTransfers;
- norace bool reqWhileTransferred;
task void grantedTask();
- task void checkResourceRequestedTask();
async command error_t Resource.request[uint8_t id]() {
signal ResourceRequested.requested[resId]();
atomic {
- if (numTransfers > 0)
- reqWhileTransferred = TRUE;
if(state == RES_IDLE) {
state = RES_GRANTING;
reqResId = id;
bool released = FALSE;
atomic {
if(state == RES_BUSY && resId == id) {
- numTransfers = 0;
- reqWhileTransferred = FALSE;
if(call Queue.isEmpty() == FALSE) {
reqResId = call Queue.dequeue();
state = RES_GRANTING;
async command bool IsResourceRequested.getNow()
{
- return reqWhileTransferred;
- }
-
- task void checkResourceRequestedTask()
- {
- if (numTransfers && reqWhileTransferred)
- signal ResourceRequested.requested[resId]();
+ return !(call Queue.isEmpty());
}
async command error_t ResourceTransferControl.transfer(uint8_t fromClient, uint8_t toClient)
{
atomic {
if (call ArbiterInfo.userId() == fromClient){
- numTransfers += 1;
call ResourceConfigure.unconfigure[fromClient]();
call ResourceConfigure.configure[resId]();
resId = toClient;
- post checkResourceRequestedTask();
return SUCCESS;
}
- }
+ }
return FAIL;
}
-
- async command error_t ResourceTransferControl.release(uint8_t client)
- {
- return call Resource.release[client]();
- }
/**
Check if the Resource is currently in use
BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
BeaconTransmitP.Token -> BeaconTxRadioClient;
+ BeaconTransmitP.IsTokenRequested -> BeaconTxRadioClient;
BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
BeaconSynchronizeP.IsBeaconEnabledPAN -> PibP.IsBeaconEnabledPAN;
BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_CLIENT];
BeaconSynchronizeP.Token -> SyncRadioClient;
+ BeaconSynchronizeP.IsTokenRequested -> SyncRadioClient;
BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
BeaconSynchronizeP.TimeCalc -> PibP;
DeviceCap.IndirectTxWaitAlarm = Alarm5;
DeviceCap.BroadcastAlarm = Alarm6;
DeviceCap.Token -> DeviceCapRadioClient;
+ DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
DeviceCap.TokenToCfp -> DeviceCapRadioClient;
DeviceCap.TokenTransferred -> DeviceCapRadioClient;
- DeviceCap.TokenRequested -> DeviceCapRadioClient;
- DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
DeviceCap.CapStart -> BeaconSynchronizeP.CapStart;
DeviceCap.CapStartRefTime -> BeaconSynchronizeP.CapStartRefTime;
DeviceCap.CapLen -> BeaconSynchronizeP.CapLen;
CoordCap.Token -> CoordCapRadioClient;
CoordCap.TokenToCfp -> CoordCapRadioClient;
CoordCap.TokenTransferred -> CoordCapRadioClient;
- CoordCap.TokenRequested -> CoordCapRadioClient;
CoordCap.IsTokenRequested -> CoordCapRadioClient;
CoordCap.CapStart -> BeaconTransmitP.CapStart;
CoordCap.CapStartRefTime -> BeaconTransmitP.CapStartRefTime;
components new RadioClientC() as DeviceCfpRadioClient;
PibP.MacReset -> DeviceCfp;
- DeviceCfp.Token -> DeviceCfpRadioClient;
DeviceCfp.TokenTransferred -> DeviceCfpRadioClient;
DeviceCfp.TokenRequested -> DeviceCfpRadioClient;
DeviceCfp.TokenToBeaconSync -> DeviceCfpRadioClient;
components new RadioClientC() as CoordCfpRadioClient;
PibP.MacReset -> CoordCfp;
- CoordCfp.Token -> CoordCfpRadioClient;
CoordCfp.TokenTransferred -> CoordCfpRadioClient;
CoordCfp.TokenRequested -> CoordCfpRadioClient;
+ CoordCfp.IsTokenRequested -> CoordCfpRadioClient;
CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
CoordCfp.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
CoordCfp.CfpEnd -> BeaconTransmitP.CfpEnd;
#define CapP_TOO_SHORT 0
#define CapP_SET_CAP_END 1
#define CapP_CAP_END_FIRED 2
+#define CapP_INTERNAL_ERROR 3
#define DeviceCapTransmitP_CONTINUE 0
#define DeviceCapTransmitP_TOVERFLOW 1
interface Alarm<TSymbolIEEE802154,uint32_t> as TrackAlarm;
interface RadioRx as BeaconRx;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface DataRequest;
interface FrameRx as CoordRealignmentRx;
interface Resource as Token;
+ interface GetNow<bool> as IsTokenRequested;
interface ResourceTransfer as TokenToCap;
interface ResourceTransferred as TokenTransferred;
interface GetNow<bool> as IsSendingBeacons;
interface Alarm<TSymbolIEEE802154,uint32_t> as BeaconTxAlarm;
interface Timer<TSymbolIEEE802154> as BeaconPayloadUpdateTimer;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface RadioTx as BeaconTx;
interface MLME_GET;
interface MLME_SET;
interface Resource as Token;
+ interface GetNow<bool> as IsTokenRequested;
interface ResourceTransfer as TokenToBroadcast;
interface ResourceTransferred as TokenTransferred;
interface FrameTx as RealignmentBeaconEnabledTx;
interface FrameTx as CfpTx;
interface Purge;
} uses {
- interface Resource as Token;
interface ResourceTransferred as TokenTransferred;
- interface ResourceRequested as TokenRequested;
interface ResourceTransfer as TokenToBeaconTransmit;
+ interface ResourceRequested as TokenRequested;
+ interface GetNow<bool> as IsTokenRequested;
interface GetNow<bool> as IsTrackingBeacons;
interface GetNow<uint32_t> as CfpEnd;
interface GetNow<ieee154_reftime_t*> as CapStartRefTime;
async event void TokenTransferred.transferred()
{
// the CFP has started, this component now owns the token -
- // because GTS is not implemented we release the token
- // (or pass it back to BeaconTransmitP if
- // we are not tracking beacons)
- if (call IsTrackingBeacons.getNow())
- call Token.release();
- else
- call TokenToBeaconTransmit.transfer();
+ // because GTS is not implemented we pass it back to the
+ // BeaconTransmitP component
+ // Note: this component must not use the Resource
+ // interface to release the token!
+ call TokenToBeaconTransmit.transfer();
}
async event void CfpEndAlarm.fired() {}
async event void TokenRequested.requested()
{
- // someone (e.g. SCAN component) requested access to the radio,
- // you might want to release the token...
+ // someone (e.g. SCAN component) requested access to the radio, we
+ // should pass the token back to BeaconTransmitP, which can release it
+ // call TokenToBeaconTransmit.transfer();
}
async event void TokenRequested.immediateRequested(){ }
- event void Token.granted(){ }
}
interface RadioTx;
interface RadioRx;
interface RadioOff;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface MLME_GET;
interface MLME_SET;
interface Ieee802154Debug as Debug;
interface FrameTx as CfpTx;
interface Purge;
} uses {
- interface Resource as Token;
interface ResourceTransferred as TokenTransferred;
interface ResourceRequested as TokenRequested;
interface ResourceTransfer as TokenToBeaconSync;
async event void TokenTransferred.transferred()
{
- // the CFP has started, this component now owns the token.
- // because GTS is not implemented we release the token
- // (or pass it back to BeaconSynchronizeP if
- // we are not transmitting beacons)
- if (call IsSendingBeacons.getNow())
- call Token.release();
- else
- call TokenToBeaconSync.transfer();
+ // the CFP has started, this component now owns the token -
+ // because GTS is not implemented we pass it back to the
+ // BeaconTransmitP component
+ // Note: this component must not use the Resource
+ // interface to release the token!
+ call TokenToBeaconSync.transfer();
}
async event void CfpEndAlarm.fired() {}
async event void TokenRequested.requested()
{
- // someone requested access to the radio, you might
- // consider releasing it...
+ // someone (e.g. SCAN component) requested access to the radio, we
+ // should pass the token back to BeaconSynchronizeP, which can release it
+ // call TokenToBeaconSync.transfer();
}
async event void TokenRequested.immediateRequested(){ }
- event void Token.granted(){ }
}
{
interface Ieee802154Debug as Debug;
interface Timer<TSymbolIEEE802154> as RxEnableTimer;
- interface Get<bool> as IsBeaconEnabledPAN;
+ interface GetNow<bool> as IsBeaconEnabledPAN;
interface Get<ieee154_macPanCoordinator_t> as IsMacPanCoordinator;
interface GetNow<bool> as IsTrackingBeacons;
interface GetNow<uint32_t> as IncomingSfStart;
interface ResourceTransferControl
{
async command error_t transfer(uint8_t fromClient, uint8_t toClient);
- async command error_t release(uint8_t client);
}
/**
* Ownership of a resource is transferred, possibly overriding the default
* queueing policy. This event is similar to an async Resource.granted()
- * event, but when a the resource is released, it is released on behalf of
- * the client who was last signalled the Resource.granted() event.
+ * event, initiated by the previous owner of the resource.
*
* @see ResourceTransfer interface
*/