2) made some small fixes/modifications to facilitate porting to micaz, as proposed by Daniel F. PiƱeiro Santos
/***************** StartupAlarm Events ****************/
async event void StartupAlarm.fired() {
if ( m_state == S_VREG_STARTING ) {
- cc2420_status_t status;
- do {
- status = call SNOP.strobe();
- } while (!(status & CC2420_STATUS_XOSC16M_STABLE));
m_state = S_VREG_STARTED;
call RSTN.clr();
call RSTN.set();
interface RadioOff;
interface DataRequest;
interface FrameRx as CoordRealignmentRx;
- interface Resource as Token;
- interface GetNow<bool> as IsTokenRequested;
- interface ResourceTransferred as TokenTransferred;
- interface ResourceTransfer as TokenToCap;
+ interface TransferableResource as RadioToken;
interface TimeCalc;
interface IEEE154Frame as Frame;
interface Leds;
m_updateTrackBeacon = trackBeacon;
m_updatePending = TRUE;
atomic {
- // if we are tracking then we'll get the Token automatically,
+ // if we are tracking then we'll get the RadioToken automatically,
// otherwise request it now
- if (!m_tracking && !call Token.isOwner())
- call Token.request();
+ if (!m_tracking && !call RadioToken.isOwner())
+ call RadioToken.request();
}
}
}
return status;
}
- event void Token.granted()
+ event void RadioToken.granted()
{
dbg_serial("BeaconSynchronizeP","Got token, expecting beacon in %lu\n",
(uint32_t) ((m_lastBeaconRxTime + m_dt) - call TrackAlarm.getNow()));
trackNextBeacon();
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t clientFrom)
{
dbg_serial("BeaconSynchronizeP","Token.transferred(), expecting beacon in %lu symbols.\n",
(uint32_t) ((m_lastBeaconRxTime + m_dt) - call TrackAlarm.getNow()));
- 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
- dbg_serial("BeaconSynchronizeP", "Token is requested, releasing it now.\n");
- call Token.request();
- call Token.release();
- } else if (m_updatePending)
+ if (m_updatePending)
post signalGrantedTask();
else
trackNextBeacon();
task void signalGrantedTask()
{
- signal Token.granted();
+ signal RadioToken.granted();
}
void trackNextBeacon()
bool missed = FALSE;
if (m_state != S_INITIAL_SCAN) {
- // we have received at least one previous beacon
- m_state = S_PREPARE;
+
if (!m_tracking) {
// nothing to do, just give up the token
dbg_serial("BeaconSynchronizeP", "Stop tracking.\n");
- call Token.release();
+ call RadioToken.release();
return;
}
+
+ // we have received at least one previous beacon
+ m_state = S_PREPARE;
while (call TimeCalc.hasExpired(m_lastBeaconRxTime, m_dt)) { // missed a beacon!
dbg_serial("BeaconSynchronizeP", "Missed a beacon, expected it: %lu, now: %lu\n",
m_lastBeaconRxTime + m_dt, call TrackAlarm.getNow());
m_dt += m_beaconInterval;
m_numBeaconsLost++;
}
+
if (m_numBeaconsLost >= IEEE154_aMaxLostBeacons) {
dbg_serial("BeaconSynchronizeP", "Missed too many beacons.\n");
post processBeaconTask();
return;
}
+
if (missed) {
// let other components get a chance to use the radio
- call Token.request();
+ call RadioToken.request();
dbg_serial("BeaconSynchronizeP", "Allowing other components to get the token.\n");
- call Token.release();
+ call RadioToken.release();
return;
}
}
+
if (call RadioOff.isOff())
signal RadioOff.offDone();
else
call MLME_GET.phyCurrentPage(),
NULL);
} else
- call Token.request(); // make another request again (before giving the token up)
+ call RadioToken.request(); // make another request again (before giving the token up)
- call Token.release();
+ call RadioToken.release();
} else {
// got the beacon!
uint8_t *payload = (uint8_t *) m_beaconPtr->data;
m_tracking = FALSE;
dbg_serial("BeaconSynchronizeP", "Stop tracking.\n");
if (m_updatePending) // there is already a new request ...
- call Token.request();
- call Token.release();
+ call RadioToken.request();
+ call RadioToken.release();
} else {
dbg_serial("BeaconSynchronizeP", "Handing over to CAP.\n");
- call TokenToCap.transfer();
+ // we pass on the token now, but make a reservation to get it back
+ // to receive the next beacon (at the start of the next superframe)
+ call RadioToken.request();
+ call RadioToken.transferTo(RADIO_CLIENT_DEVICECAP);
}
if (pendAddrSpec & PENDING_ADDRESS_SHORT_MASK)
command error_t TrackSingleBeacon.start()
{
// Track a single beacon now
- if (!m_tracking && !m_updatePending && !call Token.isOwner()) {
+ if (!m_tracking && !m_updatePending && !call RadioToken.isOwner()) {
// find a single beacon now (treat this like a user request)
m_updateLogicalChannel = call MLME_GET.phyCurrentChannel();
m_updateTrackBeacon = FALSE;
m_stopTracking = TRUE;
m_updatePending = TRUE;
- call Token.request();
+ call RadioToken.request();
}
return SUCCESS;
}
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 TransferableResource as RadioToken;
interface FrameTx as RealignmentBeaconEnabledTx;
interface FrameTx as RealignmentNonBeaconEnabledTx;
interface FrameRx as BeaconRequestRx;
/* function/task prototypes */
task void txDoneTask();
task void signalStartConfirmSuccessTask();
- void prepareNextBeaconTransmission();
+ void nextRound();
+ void prepareBeaconTransmission();
void continueStartRequest();
void finishRealignment(ieee154_txframe_t *frame, ieee154_status_t status);
if (m_beaconOrder == 15) {
// We're not already transmitting beacons, i.e. we have to request the token
// (otherwise we'd get the token "automatically" for the next scheduled beacon).
- call Token.request();
+ call RadioToken.request();
}
// We'll continue the MLME_START operation in continueStartRequest() once we have the token
}
}
}
- task void grantedTask()
+ task void signalGrantedTask()
{
- signal Token.granted();
+ signal RadioToken.granted();
}
- event void Token.granted()
+ event void RadioToken.granted()
{
- dbg_serial("BeaconSynchronizeP","Got token, will Tx beacon in %lu\n",
- (uint32_t) ((m_lastBeaconTxTime + m_dt) - call BeaconSendAlarm.getNow()));
+ dbg_serial("BeaconSynchronizeP","Token granted.\n");
if (m_requestBitmap & REQUEST_REALIGNMENT_DONE_PENDING) {
- // unlikely to occur: we have not yet received a done()
+ // very unlikely: we have not yet received a done()
// event after sending out a realignment frame
dbg_serial("BeaconTransmitP", "Realignment pending (request: %lu) !\n", (uint32_t) m_requestBitmap);
- post grantedTask(); // spin
+ post signalGrantedTask(); // spin
return;
} else if (m_requestBitmap & REQUEST_UPDATE_SF) {
dbg_serial("BeaconTransmitP","Putting new superframe spec into operation\n");
m_requestBitmap &= ~REQUEST_UPDATE_SF;
continueStartRequest();
}
+ nextRound();
+ }
+
+ void nextRound()
+ {
if (call RadioOff.isOff())
- prepareNextBeaconTransmission();
+ prepareBeaconTransmission();
else
- ASSERT(call RadioOff.off() == SUCCESS); // will continue in prepareNextBeaconTransmission()
+ ASSERT(call RadioOff.off() == SUCCESS); // will continue in prepareBeaconTransmission()
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClientID)
{
- if (call IsTokenRequested.getNow()) {
- // some other component needs the token - we give it up for now,
- // but before make another request to get it back afterwards
- dbg_serial("BeaconTransmitP", "Token is requested, releasing it now.\n");
- call Token.request();
- call Token.release();
- } else
- post grantedTask();
+ dbg_serial("BeaconSynchronizeP","Token transferred, will Tx beacon in %lu\n",
+ (uint32_t) ((m_lastBeaconTxTime + m_dt) - call BeaconSendAlarm.getNow()));
+ if (m_requestBitmap & (REQUEST_REALIGNMENT_DONE_PENDING | REQUEST_UPDATE_SF))
+ post signalGrantedTask(); // need to be in sync context
+ else
+ nextRound();
}
async event void RadioOff.offDone()
{
- prepareNextBeaconTransmission();
+ prepareBeaconTransmission();
}
- void prepareNextBeaconTransmission()
+ void prepareBeaconTransmission()
{
if (m_txState == S_TX_LOCKED) {
// have not had time to finish processing the last sent beacon
dbg_serial("BeaconTransmitP", "Token was returned too fast!\n");
- post grantedTask();
+ post signalGrantedTask();
} else if (m_beaconOrder == 15) {
// we're not sending any beacons!?
dbg_serial("BeaconTransmitP", "Stop sending beacons.\n");
- call Token.release();
+ call RadioToken.release();
} else {
// get ready for next beacon transmission
atomic {
dbg_serial("BeaconTransmitP", "Beacon Tx success at %lu\n", (uint32_t) m_lastBeaconTxTime);
} else {
// Timestamp is invalid; this is bad. We need the beacon timestamp for the
- // slotted CSMA-CA, because it defines slot reference time. We can't use this superframe
+ // slotted CSMA-CA, because it defines the slot reference time. We can't use this superframe
// TODO: check if this was the initial beacon (then m_lastBeaconTxRefTime is invalid)
dbg_serial("BeaconTransmitP", "Invalid timestamp!\n");
m_dt += m_beaconInterval;
- call Token.request();
- call Token.release();
+ call RadioToken.request();
+ call RadioToken.release();
return;
}
m_battLifeExtDuration = m_battLifeExtDuration + m_battLifeExtPeriods * 20;
} else
m_battLifeExtDuration = 0;
- call TokenToBroadcast.transfer();
+
+ // we pass on the token now, but make a reservation to get it back
+ // to transmit the next beacon (at the start of the next superframe)
+ call RadioToken.request();
+ call RadioToken.transferTo(RADIO_CLIENT_COORDBROADCAST);
post txDoneTask();
}
} uses {
interface Queue<ieee154_txframe_t*>;
interface FrameTxNow as CapTransmitNow;
- interface ResourceTransfer as TokenToCap;
- interface ResourceTransferred as TokenTransferred;
+ interface TransferableResource as RadioToken;
interface SuperframeStructure as OutgoingSF;
- interface Leds;
}
}
implementation
return (m_realignmentFrame != NULL || m_queueHead != NULL);
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClient)
{
// CAP has started - are there any broadcast frames to be transmitted?
if (call OutgoingSF.isBroadcastPending()) {
m_lock = TRUE;
call CapTransmitNow.transmitNow(broadcastFrame);
}
- call TokenToCap.transfer();
+ call RadioToken.transferTo(RADIO_CLIENT_COORDCAP);
}
async event void CapTransmitNow.transmitNowDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
}
m_lock = FALSE;
}
+
+ event void RadioToken.granted(){ ASSERT(0); }
}
default event message_t* MCPS_DATA.indication(message_t* frame) { return frame; }
default command ieee154_status_t DeviceCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
+ default command ieee154_status_t BroadcastTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_PARAMETER;}
default command ieee154_status_t CoordCfpTx.transmit(ieee154_txframe_t *data) {return IEEE154_INVALID_GTS;}
+ default async command bool IsSendingBeacons.getNow() {return FALSE;}
}
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
}
uses
{
interface Timer<TSymbolIEEE802154> as IndirectTxWaitTimer;
- interface Resource as Token;
- interface GetNow<bool> as IsTokenRequested;
+ interface TransferableResource as RadioToken;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
interface GetNow<bool> as IsRxEnableActive;
interface Set<ieee154_macSuperframeOrder_t> as SetMacSuperframeOrder;
interface Set<ieee154_macPanCoordinator_t> as SetMacPanCoordinator;
return IEEE154_TRANSACTION_OVERFLOW;
} else {
setCurrentFrame(frame);
- call Token.request();
+ call RadioToken.request();
return IEEE154_SUCCESS;
}
}
- event void Token.granted()
+ event void RadioToken.granted()
{
updateState();
}
// 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
}
// Check 2: is some other operation (like MLME-SCAN or MLME-RESET) pending?
- else if (call IsTokenRequested.getNow()) {
+ else if (call IsRadioTokenRequested.getNow()) {
if (call RadioOff.isOff()) {
// nothing more to do... just release the Token
m_lock = FALSE; // unlock
dbg_serial("DispatchUnslottedCsmaP", "Token requested: releasing it.\n");
- call Token.release();
+ call RadioToken.release();
return;
} else
next = SWITCH_OFF;
}
}
- // Check 6: just make sure the radio is switched off
+ // Check 5: just make sure the radio is switched off
else {
next = trySwitchOff();
if (next == DO_NOTHING) {
// nothing more to do... just release the Token
m_lock = FALSE; // unlock
dbg_serial("DispatchUnslottedCsmaP", "Releasing token\n");
- call Token.release();
+ call RadioToken.release();
return;
}
}
async event void RadioOff.offDone() { m_lock = FALSE; updateState();}
async event void RadioRx.enableRxDone() { m_lock = FALSE; updateState();}
- event void RxEnableStateChange.notify(bool whatever) { updateState();}
+ event void RxEnableStateChange.notify(bool whatever) {
+ if (!call RadioToken.isOwner())
+ call RadioToken.request();
+ else
+ updateState();
+ }
event void IndirectTxWaitTimer.fired()
{
uint8_t *payload = (uint8_t *) frame->data;
uint8_t *mhr = MHR(frame);
uint8_t frameType = mhr[MHR_INDEX_FC1] & FC1_FRAMETYPE_MASK;
+
+ dbg("DispatchUnslottedCsmaP", "Received frame, DSN: %lu, result: 0x%lx\n", (uint32_t) mhr[MHR_INDEX_SEQNO]);
if (frameType == FC1_FRAMETYPE_CMD)
frameType += payload[0];
atomic {
command error_t WasRxEnabled.enable() {return FAIL;}
command error_t WasRxEnabled.disable() {return FAIL;}
default event void MLME_START.confirm(ieee154_status_t status) {}
+ async event void RadioToken.transferredFrom(uint8_t fromClientID) {ASSERT(0);}
}
interface IEEE154Frame as Frame;
interface IEEE154BeaconFrame as BeaconFrame;
interface Get<uint64_t> as GetLocalExtendedAddress;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
interface Notify<const void*> as PIBUpdate[uint8_t PIBAttributeID];
interface Packet;
interface TimeCalc;
interface Init as MacReset;
interface SplitControl as RadioControl;
interface Random;
- interface Resource as Token;
+ interface TransferableResource as RadioToken;
interface RadioOff;
interface LocalTime<TSymbolIEEE802154>;
}
ieee154_PIB_t m_pib;
uint8_t m_numResetClientPending;
bool m_setDefaultPIB;
- uint8_t m_resetSpin;
+ norace uint8_t m_resetSpin;
#ifdef IEEE154_EXTENDED_ADDRESS
const uint64_t m_aExtendedAddressLE = IEEE154_EXTENDED_ADDRESS;
command error_t LocalInit.init()
{
#ifndef IEEE154_EXTENDED_ADDRESS
- uint32_t *p = (uint32_t*) &m_aExtendedAddressLE;
- *p++ = call Random.rand32();
- *p = call Random.rand32();
+ m_aExtendedAddressLE = (((uint64_t) call Random.rand32() ) << 32 ) | call Random.rand32();
#endif
resetAttributesToDefault();
return SUCCESS;
status = IEEE154_TRANSACTION_OVERFLOW; // must first cancel promiscuous mode!
else {
m_setDefaultPIB = SetDefaultPIB;
- if (!call Token.isOwner())
- call Token.request();
+ m_resetSpin = 5;
+ call RadioToken.request();
}
dbg_serial("PibP", "MLME_RESET.request(%lu) -> result: %lu\n",
(uint32_t) SetDefaultPIB, (uint32_t) status);
return status;
}
- event void Token.granted()
+ event void RadioToken.granted()
{
if (call RadioOff.off() != SUCCESS)
signal RadioOff.offDone();
call DispatchReset.init(); // resets the dispatch component(s), spools out frames
call DispatchQueueReset.init(); // resets the dispatch queue component(s), spools out frames
call MacReset.init(); // resets the remaining components
- m_resetSpin = 5;
post resetSpinTask();
}
task void resetSpinTask()
{
- if (m_resetSpin == 2) {
- // just to be safe...
- call DispatchReset.init();
- call DispatchQueueReset.init();
- call MacReset.init();
- }
- if (m_resetSpin--) {
+ m_resetSpin -= 1;
+ if (m_resetSpin != 0) {
post resetSpinTask();
return;
}
ASSERT(call RadioControl.start() == SUCCESS);
}
+ async command token_requested_t IsRadioTokenRequested.getNow(){ return m_resetSpin != 0; }
+
event void RadioControl.startDone(error_t error)
{
if (m_setDefaultPIB)
signal PIBUpdate.notify[IEEE154_macShortAddress](&m_pib.macShortAddress);
signal PIBUpdate.notify[IEEE154_macPanCoordinator](&m_pib.macPanCoordinator);
}
- call Token.release();
+ call RadioToken.release();
signal MLME_RESET.confirm(IEEE154_SUCCESS);
}
default event void PIBUpdate.notify[uint8_t PIBAttributeID](const void* PIBAttributeValue) {}
command error_t PIBUpdate.enable[uint8_t PIBAttributeID]() {return FAIL;}
command error_t PIBUpdate.disable[uint8_t PIBAttributeID]() {return FAIL;}
+ async event void RadioToken.transferredFrom(uint8_t fromClient){ASSERT(0);}
}
interface SplitControl as PromiscuousMode;
interface Get<bool> as PromiscuousModeGet;
interface FrameRx;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
} uses {
- interface Resource as Token;
+ interface TransferableResource as RadioToken;
interface RadioRx as PromiscuousRx;
interface RadioOff;
interface Set<bool> as RadioPromiscuousMode;
error_t result = FAIL;
if (m_state == S_STOPPED) {
m_state = S_STARTING;
- call Token.request();
+ call RadioToken.request();
result = SUCCESS;
}
dbg_serial("PromiscuousModeP", "PromiscuousMode.start -> result: %lu\n", (uint32_t) result);
return result;
}
- event void Token.granted()
+ event void RadioToken.granted()
{
call RadioPromiscuousMode.set(TRUE);
if (call RadioOff.isOff())
{
call RadioPromiscuousMode.set(FALSE);
m_state = S_STOPPED;
- call Token.release();
+ call RadioToken.release();
dbg_serial("PromiscuousModeP", "Promiscuous mode disabled.\n");
signal PromiscuousMode.stopDone(SUCCESS);
}
post continueStopTask();
}
+ async command token_requested_t IsRadioTokenRequested.getNow(){ return m_state == S_STARTING; }
default event void PromiscuousMode.startDone(error_t error) {}
default event void PromiscuousMode.stopDone(error_t error) {}
+ async event void RadioToken.transferredFrom(uint8_t clientFrom){ASSERT(0);}
}
*/
#include "TKN154_MAC.h"
-generic configuration RadioClientC()
+generic configuration RadioClientC(uint8_t clientID)
{
provides
{
interface RadioTx;
interface SlottedCsmaCa;
interface UnslottedCsmaCa;
- interface Resource as Token;
- interface ResourceRequested as TokenRequested;
- interface ResourceTransfer;
- interface ResourceTransferred;
- interface ResourceTransferConnector as TransferFrom;
- interface GetNow<bool> as IsResourceRequested;
- } uses {
- interface ResourceTransferConnector as TransferTo;
+ interface TransferableResource as RadioToken;
}
}
implementation
{
- enum {
- CLIENT = unique(IEEE802154_RADIO_RESOURCE),
- };
-
components RadioControlP;
- RadioRx = RadioControlP.RadioRx[CLIENT];
- RadioTx = RadioControlP.RadioTx[CLIENT];
- RadioOff = RadioControlP.RadioOff[CLIENT];
- SlottedCsmaCa = RadioControlP.SlottedCsmaCa[CLIENT];
- UnslottedCsmaCa = RadioControlP.UnslottedCsmaCa[CLIENT];
- Token = RadioControlP.Token[CLIENT];
- IsResourceRequested = RadioControlP.IsResourceRequested;
- TokenRequested = RadioControlP.TokenRequested[CLIENT];
-
- components new TransferClientP(CLIENT);
- ResourceTransfer = TransferClientP;
- ResourceTransferred = TransferClientP;
- TransferTo = TransferClientP;
- TransferFrom = TransferClientP;
- TransferClientP.ResourceTransferControl -> RadioControlP;
- TransferClientP.Leds -> RadioControlP;
+ RadioRx = RadioControlP.RadioRx[clientID];
+ RadioTx = RadioControlP.RadioTx[clientID];
+ RadioOff = RadioControlP.RadioOff[clientID];
+ SlottedCsmaCa = RadioControlP.SlottedCsmaCa[clientID];
+ UnslottedCsmaCa = RadioControlP.UnslottedCsmaCa[clientID];
+ RadioToken = RadioControlP.TransferableResource[clientID];
}
interface SlottedCsmaCa as SlottedCsmaCa[uint8_t client];
interface UnslottedCsmaCa as UnslottedCsmaCa[uint8_t client];
interface RadioOff as RadioOff[uint8_t client];
- interface Resource as Token[uint8_t client];
- interface ResourceRequested as TokenRequested[uint8_t client];
- interface ResourceTransferControl as TokenTransferControl;
- interface GetNow<bool> as IsResourceRequested;
- interface Leds as LedsRadioClient;
+ interface TransferableResource[uint8_t id];
+ interface ResourceRequested[uint8_t id];
} uses {
interface RadioRx as PhyRx;
interface RadioTx as PhyTx;
interface UnslottedCsmaCa as PhyUnslottedCsmaCa;
interface RadioOff as PhyRadioOff;
interface Get<bool> as RadioPromiscuousMode;
+ interface ResourceConfigure[uint8_t id];
interface Leds;
}
}
PhyRadioOff = RadioControlImplP.PhyRadioOff;
RadioPromiscuousMode = RadioControlImplP;
Leds = RadioControlImplP;
- LedsRadioClient = Leds;
- components new SimpleRoundRobinTransferArbiterC(IEEE802154_RADIO_RESOURCE) as Arbiter;
- Token = Arbiter;
- TokenRequested = Arbiter;
- TokenTransferControl = Arbiter;
- IsResourceRequested = Arbiter;
+ components MainC;
+ components new RoundRobinResourceQueueC(uniqueCount(IEEE802154_RADIO_RESOURCE)) as Queue;
+ components new SimpleTransferArbiterP() as Arbiter;
+
+ MainC.SoftwareInit -> Queue;
+
+ TransferableResource = Arbiter;
+ ResourceRequested = Arbiter;
RadioControlImplP.ArbiterInfo -> Arbiter;
+ ResourceConfigure = Arbiter;
+
+ Arbiter.Queue -> Queue;
}
interface Init;
interface MLME_SCAN;
interface MLME_BEACON_NOTIFY;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
}
uses
{
interface Timer<TSymbolIEEE802154> as ScanTimer;
interface Pool<ieee154_txframe_t> as TxFramePool;
interface Pool<ieee154_txcontrol_t> as TxControlPool;
- interface Resource as Token;
+ interface TransferableResource as RadioToken;
interface FrameUtility;
interface Leds;
}
uint8_t m_resultIndex;
ieee154_macPANId_t m_PANID;
norace uint32_t m_scanDuration;
- bool m_busy = FALSE;
+ norace bool m_busy = FALSE;
void nextIteration();
void continueScanRequest();
command error_t Init.init()
{
- // triggered by MLME_RESET; remember: Init will not be called
- // while this component owns the Token, so the worst case is
+ // triggered by MLME_RESET; Note: Init will not be called
+ // while this component owns the RadioToken, so the worst case is
// that a MLME_SCAN was accepted (returned IEEE154_SUCCESS)
- // but the Token.granted() has not been signalled
+ // but the RadioToken.granted() has not been signalled
if (m_busy) {
m_currentChannelNum = 27;
nextIteration(); // signals confirm and resets state
}
if (m_resultList == NULL)
m_resultListNumEntries = 0;
- call Token.request();
+ call RadioToken.request();
}
dbg_serial("ScanP", "MLME_SCAN.request -> result: %lu\n", (uint32_t) status);
return status;
}
- event void Token.granted()
+ event void RadioToken.granted()
{
if (call RadioOff.isOff())
continueScanRequest();
ieee154_macDSN_t dsn = call MLME_GET.macDSN();
if (!m_busy) {
- call Token.release();
+ call RadioToken.release();
return;
}
switch (m_scanType) {
call TxFramePool.put(m_txFrame);
}
m_txFrame = NULL;
- if (call Token.isOwner())
- call Token.release();
+ if (call RadioToken.isOwner())
+ call RadioToken.release();
m_busy = FALSE;
dbg_serial("ScanP", "MLME_SCAN.confirm()\n");
signal MLME_SCAN.confirm (
IEEE154_SUPPORTED_CHANNELPAGE,
m_unscannedChannels,
(m_scanType == ENERGY_DETECTION_SCAN) ? m_resultIndex : 0,
- (m_scanType == ENERGY_DETECTION_SCAN) ? (uint8_t*) m_resultList : NULL,
+ (m_scanType == ENERGY_DETECTION_SCAN) ? (int8_t*) m_resultList : NULL,
((m_scanType == ACTIVE_SCAN ||
m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? m_resultIndex : 0,
((m_scanType == ACTIVE_SCAN ||
m_scanType == PASSIVE_SCAN) && m_macAutoRequest) ? (ieee154_PANDescriptor_t*) m_resultList : NULL);
}
+ dbg_serial_flush();
}
async event void RadioRx.enableRxDone()
nextIteration();
}
+ async command token_requested_t IsRadioTokenRequested.getNow(){ return m_busy;}
+ async event void RadioToken.transferredFrom(uint8_t id){ ASSERT(0);}
default event message_t* MLME_BEACON_NOTIFY.indication (message_t *beaconFrame) {return beaconFrame;}
default event void MLME_SCAN.confirm (
ieee154_status_t status,
+++ /dev/null
-/*
- * "Copyright (c) 2005 Washington University in St. Louis.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice, the following
- * two paragraphs and the author appear in all copies of this software.
- *
- * IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
- * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
- * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
- * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
- * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
- * MODIFICATIONS."
- */
-
-/*
- * Copyright (c) 2004, Technische Universitat Berlin
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitat Berlin nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/**
- * Please refer to TEP 108 for more information about this component and its
- * intended use.<br><br>
- *
- * This component provides the Resource, ArbiterInfo, and Resource
- * Controller interfaces and uses the ResourceConfigure interface as
- * described in TEP 108. It provides arbitration to a shared resource in
- * an FCFS fashion. An array is used to keep track of which users have put
- * in requests for the resource. Upon the release of the resource by one
- * of these users, the array is checked and the next user (in FCFS order)
- * that has a pending request will ge granted control of the resource. If
- * there are no pending requests, then the resource becomes idle and any
- * user can put in a request and immediately receive access to the
- * Resource.
- *
- * @param <b>resourceName</b> -- The name of the Resource being shared
- *
- * @author Kevin Klues (klues@tkn.tu-berlin.de)
- * @author Philip Levis
- */
-
-generic configuration SimpleRoundRobinTransferArbiterC(char resourceName[]) {
- provides {
- interface Resource[uint8_t id];
- interface ResourceRequested[uint8_t id];
- interface ResourceTransferControl;
- interface ArbiterInfo;
- interface GetNow<bool> as IsResourceRequested;
- }
- uses interface ResourceConfigure[uint8_t id];
-}
-implementation {
- components MainC;
- components new RoundRobinResourceQueueC(uniqueCount(resourceName)) as Queue;
- components new SimpleTransferArbiterP() as Arbiter;
-
- MainC.SoftwareInit -> Queue;
-
- Resource = Arbiter;
- ResourceRequested = Arbiter;
- ArbiterInfo = Arbiter;
- ResourceConfigure = Arbiter;
- ResourceTransferControl = Arbiter;
- IsResourceRequested = Arbiter;
-
- Arbiter.Queue -> Queue;
-}
*
* @author Kevin Klues (klues@tkn.tu-berlin.de)
* @author Philip Levis
- * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (added resource transfer)
+ * @author: Jan Hauer <hauer@tkn.tu-berlin.de> (added TransferableResource interface)
*/
generic module SimpleTransferArbiterP() {
provides {
- interface Resource[uint8_t id];
+ interface TransferableResource as Resource[uint8_t id];
interface ResourceRequested[uint8_t id];
- interface ResourceTransferControl;
interface ArbiterInfo;
- interface GetNow<bool> as IsResourceRequested;
}
uses {
interface ResourceConfigure[uint8_t id];
return FAIL;
}
- async command bool IsResourceRequested.getNow()
- {
- return !(call Queue.isEmpty());
- }
-
- async command error_t ResourceTransferControl.transfer(uint8_t fromClient, uint8_t toClient)
+ async command error_t Resource.transferTo[uint8_t fromID](uint8_t toID)
{
atomic {
- if (call ArbiterInfo.userId() == fromClient) {
- call ResourceConfigure.unconfigure[fromClient]();
+ if (call ArbiterInfo.userId() == fromID) {
+ call ResourceConfigure.unconfigure[fromID]();
call ResourceConfigure.configure[resId]();
- resId = toClient;
+ resId = toID;
+ signal Resource.transferredFrom[toID](fromID); // consider moving this outside the atomic
return SUCCESS;
}
}
}
default async command void ResourceConfigure.unconfigure[uint8_t id]() {
}
+ default async event void Resource.transferredFrom[uint8_t id](uint8_t c) {
+ }
}
/* ----------------------- Scanning (MLME-SCAN) ----------------------- */
- components new RadioClientC() as ScanRadioClient;
+ components new RadioClientC(RADIO_CLIENT_SCAN) as ScanRadioClient;
PibP.MacReset -> ScanP;
ScanP.MLME_GET -> PibP;
ScanP.MLME_SET -> PibP.MLME_SET;
ScanP.ScanTimer = Timer1;
ScanP.TxFramePool -> TxFramePoolP;
ScanP.TxControlPool -> TxControlPoolP;
- ScanP.Token -> ScanRadioClient;
+ ScanP.RadioToken -> ScanRadioClient;
ScanP.Leds = Leds;
ScanP.FrameUtility -> PibP;
/* ----------------- Beacon Transmission (MLME-START) ----------------- */
- components new RadioClientC() as BeaconTxRadioClient;
+ components new RadioClientC(RADIO_CLIENT_BEACONTRANSMIT) as BeaconTxRadioClient;
PibP.MacReset -> BeaconTransmitP;
BeaconTransmitP.PIBUpdate[IEEE154_macAssociationPermit] -> PibP.PIBUpdate[IEEE154_macAssociationPermit];
BeaconTransmitP.PIBUpdate[IEEE154_macGTSPermit] -> PibP.PIBUpdate[IEEE154_macGTSPermit];
BeaconTransmitP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder;
BeaconTransmitP.SetMacBeaconTxTime -> PibP.SetMacBeaconTxTime;
BeaconTransmitP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
- BeaconTransmitP.Token -> BeaconTxRadioClient;
- BeaconTransmitP.IsTokenRequested -> BeaconTxRadioClient;
- BeaconTransmitP.TokenTransferred -> BeaconTxRadioClient;
- BeaconTransmitP.TokenToBroadcast -> BeaconTxRadioClient;
+ BeaconTransmitP.RadioToken -> BeaconTxRadioClient;
BeaconTransmitP.RealignmentBeaconEnabledTx -> CoordBroadcastP.RealignmentTx;
BeaconTransmitP.RealignmentNonBeaconEnabledTx -> CoordCapQueue.FrameTx[unique(CAP_TX_CLIENT)];
BeaconTransmitP.BeaconRequestRx -> CoordCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_BEACON_REQUEST];
BeaconTransmitP.IsBroadcastReady -> CoordBroadcastP.IsBroadcastReady;
BeaconTransmitP.TimeCalc -> PibP;
BeaconTransmitP.Leds = Leds;
- BeaconTxRadioClient.TransferTo -> CoordBroadcastRadioClient.TransferFrom;
/* ------------------ Beacon Tracking (MLME-SYNC) ------------------ */
- components new RadioClientC() as SyncRadioClient;
+ components new RadioClientC(RADIO_CLIENT_BEACONSYNCHRONIZE) as SyncRadioClient;
PibP.MacReset -> BeaconSynchronizeP;
BeaconSynchronizeP.MLME_SET -> PibP.MLME_SET;
BeaconSynchronizeP.MLME_GET -> PibP;
BeaconSynchronizeP.BeaconRx -> SyncRadioClient;
BeaconSynchronizeP.RadioOff -> SyncRadioClient;
BeaconSynchronizeP.DataRequest -> PollP.DataRequest[SYNC_POLL_CLIENT];
- BeaconSynchronizeP.Token -> SyncRadioClient;
- BeaconSynchronizeP.IsTokenRequested -> SyncRadioClient;
- BeaconSynchronizeP.TokenTransferred -> SyncRadioClient;
- BeaconSynchronizeP.TokenToCap -> SyncRadioClient;
+ BeaconSynchronizeP.RadioToken -> SyncRadioClient;
BeaconSynchronizeP.TimeCalc -> PibP;
BeaconSynchronizeP.CoordRealignmentRx -> DeviceCap.FrameRx[FC1_FRAMETYPE_CMD + CMD_FRAME_COORDINATOR_REALIGNMENT];
BeaconSynchronizeP.Leds = Leds;
- SyncRadioClient.TransferTo -> DeviceCapRadioClient.TransferFrom;
/* -------------------- Association (MLME-ASSOCIATE) -------------------- */
/* ---------------------------- Broadcasts ---------------------------- */
- components new RadioClientC() as CoordBroadcastRadioClient;
+ components new RadioClientC(RADIO_CLIENT_COORDBROADCAST) as CoordBroadcastRadioClient;
PibP.MacReset -> CoordBroadcastP;
- CoordBroadcastP.TokenTransferred -> CoordBroadcastRadioClient;
- CoordBroadcastP.TokenToCap -> CoordBroadcastRadioClient;
- CoordBroadcastRadioClient.TransferTo -> CoordCapRadioClient.TransferFrom;
+ CoordBroadcastP.RadioToken -> CoordBroadcastRadioClient;
CoordBroadcastP.OutgoingSF -> BeaconTransmitP.OutgoingSF;
CoordBroadcastP.CapTransmitNow -> CoordCap.BroadcastTx;
CoordBroadcastP.Queue -> BroadcastQueueC;
- CoordBroadcastP.Leds = Leds;
/* --------------------- CAP (incoming superframe) -------------------- */
CoordCapQueue.Queue -> CoordCapQueueC;
CoordCapQueue.FrameTxCsma -> CoordCap;
- components new RadioClientC() as DeviceCapRadioClient;
+ components new RadioClientC(RADIO_CLIENT_DEVICECAP) as DeviceCapRadioClient;
PibP.DispatchReset -> DeviceCap;
DeviceCap.CapEndAlarm = Alarm3;
DeviceCap.BLEAlarm = Alarm4;
DeviceCap.IndirectTxWaitAlarm = Alarm5;
DeviceCap.BroadcastAlarm = Alarm6;
- DeviceCap.Token -> DeviceCapRadioClient;
- DeviceCap.IsTokenRequested -> DeviceCapRadioClient;
- DeviceCap.TokenToCfp -> DeviceCapRadioClient;
- DeviceCap.TokenTransferred -> DeviceCapRadioClient;
+ DeviceCap.RadioToken -> DeviceCapRadioClient;
DeviceCap.SuperframeStructure -> BeaconSynchronizeP.IncomingSF;
DeviceCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+ DeviceCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+ DeviceCap.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+ DeviceCap.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
DeviceCap.GetIndirectTxFrame -> IndirectTxP;
DeviceCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange;
DeviceCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
DeviceCap.TimeCalc -> PibP;
DeviceCap.Leds = Leds;
DeviceCap.TrackSingleBeacon -> BeaconSynchronizeP.TrackSingleBeacon;
- DeviceCapRadioClient.TransferTo -> DeviceCfpRadioClient.TransferFrom;
/* ---------------------- CAP (outgoing superframe) ------------------- */
- components new RadioClientC() as CoordCapRadioClient,
+ components new RadioClientC(RADIO_CLIENT_COORDCAP) as CoordCapRadioClient,
new BackupP(ieee154_cap_frame_backup_t);
PibP.DispatchReset -> CoordCap;
CoordCap.CapEndAlarm = Alarm7;
CoordCap.BLEAlarm = Alarm8;
- CoordCap.Token -> CoordCapRadioClient;
- CoordCap.TokenToCfp -> CoordCapRadioClient;
- CoordCap.TokenTransferred -> CoordCapRadioClient;
- CoordCap.IsTokenRequested -> CoordCapRadioClient;
+ CoordCap.RadioToken -> CoordCapRadioClient;
CoordCap.SuperframeStructure -> BeaconTransmitP.OutgoingSF;
CoordCap.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+ CoordCap.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+ CoordCap.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+ CoordCap.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
CoordCap.GetIndirectTxFrame -> IndirectTxP;
CoordCap.RxEnableStateChange -> RxEnableP.RxEnableStateChange;
CoordCap.IsTrackingBeacons -> BeaconSynchronizeP.IsTrackingBeacons;
CoordCap.MLME_SET -> PibP.MLME_SET;
CoordCap.TimeCalc -> PibP;
CoordCap.Leds = Leds;
- CoordCapRadioClient.TransferTo -> CoordCfpRadioClient.TransferFrom;
CoordCap.FrameBackup -> BackupP;
CoordCap.FrameRestore -> BackupP;
/* -------------------- GTS (incoming superframe) --------------------- */
- components new RadioClientC() as DeviceCfpRadioClient;
+ components new RadioClientC(RADIO_CLIENT_DEVICECFP) as DeviceCfpRadioClient;
PibP.MacReset -> DeviceCfp;
- DeviceCfp.TokenTransferred -> DeviceCfpRadioClient;
- DeviceCfp.TokenRequested -> DeviceCfpRadioClient;
- DeviceCfp.TokenToBeaconSync -> DeviceCfpRadioClient;
+ DeviceCfp.RadioToken -> DeviceCfpRadioClient;
DeviceCfp.IncomingSF -> BeaconSynchronizeP.IncomingSF;
DeviceCfp.CfpSlotAlarm = Alarm9;
DeviceCfp.CfpEndAlarm = Alarm10;
DeviceCfp.RadioOff -> DeviceCfpRadioClient;
DeviceCfp.MLME_GET -> PibP;
DeviceCfp.MLME_SET -> PibP.MLME_SET;
- DeviceCfpRadioClient.TransferTo -> SyncRadioClient.TransferFrom;
/* -------------------- GTS (outgoing superframe) --------------------- */
- components new RadioClientC() as CoordCfpRadioClient;
+ components new RadioClientC(RADIO_CLIENT_COORDCFP) as CoordCfpRadioClient;
PibP.MacReset -> CoordCfp;
- CoordCfp.TokenTransferred -> CoordCfpRadioClient;
- CoordCfp.TokenRequested -> CoordCfpRadioClient;
- CoordCfp.TokenToBeaconTransmit -> CoordCfpRadioClient;
+ CoordCfp.RadioToken -> CoordCfpRadioClient;
CoordCfp.OutgoingSF -> BeaconTransmitP.OutgoingSF;
CoordCfp.CfpSlotAlarm = Alarm11;
CoordCfp.CfpEndAlarm = Alarm12;
CoordCfp.RadioOff -> CoordCfpRadioClient;
CoordCfp.MLME_GET -> PibP;
CoordCfp.MLME_SET -> PibP.MLME_SET;
- CoordCfpRadioClient.TransferTo -> BeaconTxRadioClient.TransferFrom;
/* -------------------------- promiscuous mode ------------------------ */
- components new RadioClientC() as PromiscuousModeRadioClient;
+ components new RadioClientC(RADIO_CLIENT_PROMISCUOUSMODE) as PromiscuousModeRadioClient;
PibP.MacReset -> PromiscuousModeP;
- PromiscuousModeP.Token -> PromiscuousModeRadioClient;
+ PromiscuousModeP.RadioToken -> PromiscuousModeRadioClient;
PromiscuousModeP.PromiscuousRx -> PromiscuousModeRadioClient;
PromiscuousModeP.RadioOff -> PromiscuousModeRadioClient;
PromiscuousModeP.RadioPromiscuousMode = RadioPromiscuousMode;
/* ------------------------------- PIB -------------------------------- */
- components new RadioClientC() as PibRadioClient;
+ components new RadioClientC(RADIO_CLIENT_PIB) as PibRadioClient;
PIBUpdate = PibP;
MainC.SoftwareInit -> PibP.LocalInit;
PibP.RadioControl = PhySplitControl;
PibP.Random = Random;
PibP.PromiscuousModeGet -> PromiscuousModeP;
PibP.LocalTime = LocalTime;
- PibP.Token -> PibRadioClient;
+ PibP.RadioToken -> PibRadioClient;
PibP.RadioOff -> PibRadioClient;
/* ------------------------- Radio Control ---------------------------- */
/* ----------------------- Scanning (MLME-SCAN) ----------------------- */
- components new RadioClientC() as ScanRadioClient;
+ components new RadioClientC(RADIO_CLIENT_SCAN) as ScanRadioClient;
PibP.MacReset -> ScanP;
ScanP.MLME_GET -> PibP;
ScanP.MLME_SET -> PibP.MLME_SET;
ScanP.ScanTimer = Timer1;
ScanP.TxFramePool -> TxFramePoolP;
ScanP.TxControlPool -> TxControlPoolP;
- ScanP.Token -> ScanRadioClient;
+ ScanP.RadioToken -> ScanRadioClient;
ScanP.Leds = Leds;
ScanP.FrameUtility -> PibP;
DispatchQueueP.Queue -> DispatchQueueC;
DispatchQueueP.FrameTxCsma -> DispatchP;
- components new RadioClientC() as DispatchRadioClient;
+ components new RadioClientC(unique(IEEE802154_RADIO_RESOURCE)) as DispatchRadioClient;
PibP.DispatchReset -> DispatchP;
DispatchP.IndirectTxWaitTimer = Timer4;
- DispatchP.Token -> DispatchRadioClient;
+ DispatchP.RadioToken -> DispatchRadioClient;
DispatchP.SetMacSuperframeOrder -> PibP.SetMacSuperframeOrder;
DispatchP.SetMacPanCoordinator -> PibP.SetMacPanCoordinator;
- DispatchP.IsTokenRequested -> DispatchRadioClient;
DispatchP.IsRxEnableActive -> RxEnableP.IsRxEnableActive;
+ DispatchP.IsRadioTokenRequested -> PibP.IsRadioTokenRequested; // fan out...
+ DispatchP.IsRadioTokenRequested -> PromiscuousModeP.IsRadioTokenRequested;
+ DispatchP.IsRadioTokenRequested -> ScanP.IsRadioTokenRequested;
DispatchP.GetIndirectTxFrame -> IndirectTxP;
DispatchP.RxEnableStateChange -> RxEnableP.RxEnableStateChange;
DispatchP.FrameUtility -> PibP;
/* -------------------------- promiscuous mode ------------------------ */
- components new RadioClientC() as PromiscuousModeRadioClient;
+ components new RadioClientC(RADIO_CLIENT_PROMISCUOUSMODE) as PromiscuousModeRadioClient;
PibP.MacReset -> PromiscuousModeP;
- PromiscuousModeP.Token -> PromiscuousModeRadioClient;
+ PromiscuousModeP.RadioToken -> PromiscuousModeRadioClient;
PromiscuousModeP.PromiscuousRx -> PromiscuousModeRadioClient;
PromiscuousModeP.RadioOff -> PromiscuousModeRadioClient;
PromiscuousModeP.RadioPromiscuousMode = RadioPromiscuousMode;
/* ------------------------------- PIB -------------------------------- */
- components new RadioClientC() as PibRadioClient;
+ components new RadioClientC(RADIO_CLIENT_PIB) as PibRadioClient;
PIBUpdate = PibP;
MainC.SoftwareInit -> PibP.LocalInit;
PibP.RadioControl = PhySplitControl;
PibP.Random = Random;
PibP.PromiscuousModeGet -> PromiscuousModeP;
PibP.LocalTime = LocalTime;
- PibP.Token -> PibRadioClient;
+ PibP.RadioToken -> PibRadioClient;
PibP.RadioOff -> PibRadioClient;
/* ------------------------- Radio Control ---------------------------- */
#define IEEE802154_RADIO_RESOURCE "RadioRxTxP.resource"
enum {
+ // The following identfiers map to components that access the radio
+ // via RadioClientC(). They are used as parameters for RadioClientC(),
+ // the TransferableResource.transferTo() command and in
+ // the TransferableResource.transferredFrom() event
+
+ RADIO_CLIENT_SCAN = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_PIB = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_PROMISCUOUSMODE = unique(IEEE802154_RADIO_RESOURCE),
+
+ RADIO_CLIENT_BEACONTRANSMIT = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_COORDBROADCAST = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_COORDCAP = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_COORDCFP = unique(IEEE802154_RADIO_RESOURCE),
+
+ RADIO_CLIENT_BEACONSYNCHRONIZE = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_DEVICECAP = unique(IEEE802154_RADIO_RESOURCE),
+ RADIO_CLIENT_DEVICECFP = unique(IEEE802154_RADIO_RESOURCE),
+};
+
+enum {
+ // parameter for the generic DispatchSlottedCsmaP
OUTGOING_SUPERFRAME,
INCOMING_SUPERFRAME,
};
IEEE154_aUnitBackoffPeriod = 20,
};
+// combine function for IsRadioTokenRequested (GetNow) interface
+typedef bool token_requested_t __attribute__((combine(rcombine)));
+token_requested_t rcombine(token_requested_t r1, token_requested_t r2)
+{
+ return r1 && r2;
+}
+
#ifdef TKN154_DEBUG
/******************************************************************
+++ /dev/null
-/*
- * Copyright (c) 2008, Technische Universitaet Berlin
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * - Neither the name of the Technische Universitaet Berlin nor the names
- * of its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
- * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-generic module TransferClientP(uint8_t myUserId)
-{
- provides
- {
- interface ResourceTransfer;
- interface ResourceTransferred;
- interface ResourceTransferConnector as TransferredFrom;
- } uses {
- interface ResourceTransferConnector as TransferTo;
- interface ResourceTransferControl;
- interface Leds;
- }
-}
-implementation
-{
- async command error_t ResourceTransfer.transfer()
- {
- error_t result;
- uint8_t toClient = call TransferTo.getUserId();
- atomic {
- result = call ResourceTransferControl.transfer(myUserId, toClient);
- if (result == SUCCESS)
- call TransferTo.transfer();
- }
- return result;
- }
-
- async command uint8_t TransferredFrom.getUserId() { return myUserId;}
-
- async command void TransferredFrom.transfer()
- {
- signal ResourceTransferred.transferred();
- }
- default async command uint8_t TransferTo.getUserId() { ASSERT(0); return 0xFF;}
- default async command void TransferTo.transfer() { ASSERT(0); }
- default async event void ResourceTransferred.transferred() {}
-}
interface RadioOff;
interface DataRequest;
interface FrameRx as CoordRealignmentRx;
- interface Resource as Token;
- interface GetNow<bool> as IsTokenRequested;
- interface ResourceTransferred as TokenTransferred;
- interface ResourceTransfer as TokenToCap;
+ interface TransferableResource as RadioToken;
interface TimeCalc;
interface IEEE154Frame as Frame;
interface Leds;
return IEEE154_TRANSACTION_OVERFLOW;
}
- event void Token.granted() { }
+ event void RadioToken.granted() { }
- async event void TokenTransferred.transferred() { }
+ async event void RadioToken.transferredFrom(uint8_t fromClient) { call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT); }
async event void RadioOff.offDone() { }
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 TransferableResource as RadioToken;
interface FrameTx as RealignmentBeaconEnabledTx;
interface FrameTx as RealignmentNonBeaconEnabledTx;
interface FrameRx as BeaconRequestRx;
return IEEE154_TRANSACTION_OVERFLOW;
}
- event void Token.granted() { }
+ event void RadioToken.granted() { }
- async event void TokenTransferred.transferred() { call Token.release(); }
+ async event void RadioToken.transferredFrom(uint8_t from) { call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE); }
async event void RadioOff.offDone() { }
} uses {
interface Queue<ieee154_txframe_t*>;
interface FrameTxNow as CapTransmitNow;
- interface ResourceTransfer as TokenToCap;
- interface ResourceTransferred as TokenTransferred;
+ interface TransferableResource as RadioToken;
interface GetNow<bool> as BeaconFramePendingBit;
interface SuperframeStructure as OutgoingSF;
interface Leds;
return FALSE;
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClient)
{
- call TokenToCap.transfer();
+ call RadioToken.transferTo(RADIO_CLIENT_COORDCAP);
}
async event void CapTransmitNow.transmitNowDone(ieee154_txframe_t *txFrame, ieee154_status_t status)
{
}
+ event void RadioToken.granted(){ }
}
interface FrameTx as CfpTx;
interface Purge;
} uses {
- interface ResourceTransferred as TokenTransferred;
- interface ResourceTransfer as TokenToBeaconTransmit;
- interface ResourceRequested as TokenRequested;
+ interface TransferableResource as RadioToken;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpSlotAlarm;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpEndAlarm;
interface SuperframeStructure as OutgoingSF;
return IEEE154_INVALID_HANDLE;
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClient)
{
// the CFP has started, this component now owns the token -
- // because GTS is not implemented we pass it back to the
- // BeaconTransmitP component
- call TokenToBeaconTransmit.transfer();
+ // because GTS is not implemented we pass it on
+#ifndef IEEE154_BEACON_SYNC_DISABLED
+ call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE);
+#else
+ call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT);
+#endif
}
async event void CfpEndAlarm.fired() {}
async event void RadioRx.enableRxDone(){}
event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp){return frame;}
- async event void TokenRequested.requested()
+ event void RadioToken.granted()
{
- // 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(){ }
+ ASSERT(0); // should never happen, because we never call RadioToken.request()
+ }
}
interface FrameTx as CfpTx;
interface Purge;
} uses {
- interface ResourceTransferred as TokenTransferred;
- interface ResourceRequested as TokenRequested;
- interface ResourceTransfer as TokenToBeaconSync;
+ interface TransferableResource as RadioToken;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpSlotAlarm;
interface Alarm<TSymbolIEEE802154,uint32_t> as CfpEndAlarm;
interface SuperframeStructure as IncomingSF;
return IEEE154_INVALID_HANDLE;
}
- async event void TokenTransferred.transferred()
+ async event void RadioToken.transferredFrom(uint8_t fromClient)
{
// the CFP has started, this component now owns the token -
- // because GTS is not implemented we pass it back to the
- // BeaconTransmitP component
- call TokenToBeaconSync.transfer();
+ // because GTS is not implemented we pass it on
+#ifndef IEEE154_BEACON_TX_DISABLED
+ call RadioToken.transferTo(RADIO_CLIENT_BEACONTRANSMIT);
+#else
+ call RadioToken.transferTo(RADIO_CLIENT_BEACONSYNCHRONIZE);
+#endif
}
async event void CfpEndAlarm.fired() {}
async event void RadioRx.enableRxDone(){}
event message_t* RadioRx.received(message_t *frame, const ieee154_timestamp_t *timestamp){return frame;}
- async event void TokenRequested.requested()
+ event void RadioToken.granted()
{
- // 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(){ }
+ ASSERT(0); // should never happen, because we never call RadioToken.request()
+ }
}
#include "TKN154_PHY.h"
#include "TKN154_MAC.h"
-generic module NoDispatchSlottedCsmaP(uint8_t superframeDirection)
+generic module NoDispatchSlottedCsmaP(uint8_t sfDirection)
{
provides
{
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 GetNow<token_requested_t> as IsRadioTokenRequested;
+ interface TransferableResource as RadioToken;
interface SuperframeStructure;
interface GetNow<bool> as IsRxEnableActive;
interface Get<ieee154_txframe_t*> as GetIndirectTxFrame;
}
implementation
{
+ enum {
+ COORD_ROLE = (sfDirection == OUTGOING_SUPERFRAME),
+ DEVICE_ROLE = !COORD_ROLE,
+ RADIO_CLIENT_CFP = COORD_ROLE ? RADIO_CLIENT_COORDCFP : RADIO_CLIENT_DEVICECFP,
+ };
+
command error_t Reset.init() { return SUCCESS; }
- async event void TokenTransferred.transferred() { }
+ async event void RadioToken.transferredFrom(uint8_t c) { call RadioToken.transferTo(RADIO_CLIENT_CFP); }
command ieee154_status_t FrameTx.transmit(ieee154_txframe_t *frame) { return IEEE154_TRANSACTION_OVERFLOW; }
event message_t* RadioRx.received(message_t* frame, const ieee154_timestamp_t *timestamp) { return frame; }
- async command ieee154_status_t BroadcastTx.transmitNow(ieee154_txframe_t *frame) { }
+ async command ieee154_status_t BroadcastTx.transmitNow(ieee154_txframe_t *frame) { return IEEE154_TRANSACTION_OVERFLOW;}
- event void Token.granted() { }
+ event void RadioToken.granted() { }
command error_t WasRxEnabled.enable(){return FAIL;}
command error_t WasRxEnabled.disable(){return FAIL;}
interface SplitControl as PromiscuousMode;
interface Get<bool> as PromiscuousModeGet;
interface FrameRx;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
} uses {
interface Resource as Token;
interface RadioRx as PromiscuousRx;
default event void PromiscuousMode.startDone(error_t error){}
default event void PromiscuousMode.stopDone(error_t error){}
+ async command token_requested_t IsRadioTokenRequested.getNow(){ return FALSE;}
}
interface Init;
interface MLME_SCAN;
interface MLME_BEACON_NOTIFY;
+ interface GetNow<token_requested_t> as IsRadioTokenRequested;
}
uses
{
interface Timer<TSymbolIEEE802154> as ScanTimer;
interface Pool<ieee154_txframe_t> as TxFramePool;
interface Pool<ieee154_txcontrol_t> as TxControlPool;
- interface Resource as Token;
+ interface TransferableResource as RadioToken;
interface FrameUtility;
interface Leds;
}
return IEEE154_TRANSACTION_OVERFLOW;
}
- event void Token.granted()
+ event void RadioToken.granted()
{
- call Token.release();
+ ASSERT(0);
}
event void EnergyDetection.done(error_t status, int8_t EnergyLevel){}
event void ScanTimer.fired() { }
async event void RadioOff.offDone() { }
+ async event void RadioToken.transferredFrom(uint8_t fromClient){ASSERT(0);}
+ async command token_requested_t IsRadioTokenRequested.getNow(){ return FALSE;}
}
+++ /dev/null
-/*
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransfer
-{
-
- /**
- * Transfers ownership of a resource to another client, which will in turn
- * be signalled a ResourceTransferred.transferred() event.
- *
- * When a resource that was transferred through this command is released, it
- * is released on behalf of the "original" client, i.e. who was last
- * signalled the Resource.granted() event and it then depends on the original
- * queueing policy which component will be granted the resource next.
- *
- * @return SUCCESS If ownership has been transferred.<br> FAIL ownership has
- * not been transferred, because the caller is not owner of the resource
- */
- async command error_t transfer();
-}
+++ /dev/null
-/*
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferConnector
-{
- async command uint8_t getUserId();
- async command void transfer();
-}
+++ /dev/null
-/*
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferControl
-{
- async command error_t transfer(uint8_t fromClient, uint8_t toClient);
-}
+++ /dev/null
-/*
- * Copyright (c) 2008, Technische Universitaet Berlin All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer. - Redistributions in
- * binary form must reproduce the above copyright notice, this list of
- * conditions and the following disclaimer in the documentation and/or other
- * materials provided with the distribution. - Neither the name of the
- * Technische Universitaet Berlin nor the names of its contributors may be used
- * to endorse or promote products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * - Revision -------------------------------------------------------------
- * $Revision$
- * $Date$
- * @author Jan Hauer <hauer@tkn.tu-berlin.de>
- * ========================================================================
- */
-
-interface ResourceTransferred
-{
-
- /**
- * Ownership of a resource is transferred, possibly overriding the default
- * queueing policy. This event is similar to an async Resource.granted()
- * event, initiated by the previous owner of the resource.
- *
- * @see ResourceTransfer interface
- */
- async event void transferred();
-}
--- /dev/null
+/*
+ * "Copyright (c) 2005 Washington University in St. Louis.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice, the following
+ * two paragraphs and the author appear in all copies of this software.
+ *
+ * IN NO EVENT SHALL WASHINGTON UNIVERSITY IN ST. LOUIS BE LIABLE TO ANY PARTY
+ * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
+ * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF WASHINGTON
+ * UNIVERSITY IN ST. LOUIS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * WASHINGTON UNIVERSITY IN ST. LOUIS SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND WASHINGTON UNIVERSITY IN ST. LOUIS HAS NO
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+ * MODIFICATIONS."
+ */
+
+/*
+ * Copyright (c) 2004, Technische Universitat Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitat Berlin nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+ /**
+ * This interface is the same as the standard <tt>Resource</tt>
+ * interface, except that it has one new command <tt>transferTo()</tt>
+ * and one new event <tt>transferred()</tt>, which allow to pass
+ * the resource from one component to another.
+ *
+ * @author Jan Hauer <hauer@tkn.tu-berlin.de>
+ */
+
+interface TransferableResource
+{
+ /**
+ * Request access to a shared resource. You must call release()
+ * when you are done with it.
+ *
+ * @return SUCCESS When a request has been accepted. The granted()
+ * event will be signaled once you have control of the
+ * resource.<br>
+ * EBUSY You have already requested this resource and a
+ * granted event is pending
+ */
+ async command error_t request();
+
+ /**
+ * Request immediate access to a shared resource. You must call release()
+ * when you are done with it.
+ *
+ * @return SUCCESS When a request has been accepted. <br>
+ * FAIL The request cannot be fulfilled
+ */
+ async command error_t immediateRequest();
+
+ /**
+ * You are now in control of the resource.
+ */
+ event void granted();
+
+ /**
+ * Transfers ownership of a resource to another client, which will in turn
+ * be signalled the <tt>transferred()</tt> event. This command may override
+ * the default queueing policy.
+ *
+ * @param dstClient The identifier of the client to transfer the resource to.
+ *
+ * @return SUCCESS If ownership has been transferred; FAIL if ownership has
+ * not been transferred, because the caller is not owner of the resource or
+ * a client with the identifer <tt>dstClient</tt> is not present.
+ */
+ async command error_t transferTo(uint8_t dstClient);
+
+ /**
+ * Another client transferred ownership of the resource to you by calling
+ * the <tt>transfer()</tt> command, i.e. you are now in control of the resource.
+ *
+ * @param srcClient The identifier of the client that transferred the resource to you.
+ */
+ async event void transferredFrom(uint8_t srcClient);
+
+ /**
+ * Release a shared resource you previously acquired.
+ *
+ * @return SUCCESS The resource has been released <br>
+ * FAIL You tried to release but you are not the
+ * owner of the resource
+ *
+ * @note This command should never be called between putting in a request
+ * and waiting for a granted event. Doing so will result in a
+ * potential race condition. There are ways to guarantee that no
+ * race will occur, but they are clumsy and overly complicated.
+ * Since it doesn't logically make since to be calling
+ * <code>release</code> before receiving a <code>granted</code> event,
+ * we have opted to keep thing simple and warn you about the potential
+ * race.
+ */
+ async command error_t release();
+
+ /**
+ * Check if the user of this interface is the current
+ * owner of the Resource
+ * @return TRUE It is the owner <br>
+ * FALSE It is not the owner
+ */
+ async command bool isOwner();
+}
#else
typedef struct {
uint8_t control; // stores length (lower 7 bits), top bit -> promiscuous mode
- uint8_t mhr[23]; // maximum header size without security
+ uint8_t mhr[MHR_MAX_LEN]; // maximum header size without security
} ieee154_header_t;
typedef struct {