#include "PacketAck.h"
#include "RedMac.h"
+#ifdef DELTATIMEDEBUG
+#include "DeltaTrace.h"
+#endif
+
module RedMacP {
provides {
interface Init;
interface Sleeptime;
interface Teamgeist;
interface ChannelCongestion;
+#ifdef MAC_EVAL
+ interface MacEval;
+#endif
}
uses {
interface StdControl as CcaStdControl;
#ifdef REDMAC_PERFORMANCE
interface Performance;
#endif
-
+#ifdef DELTATIMEDEBUG
+ interface DeltaTrace;
+#endif
}
}
implementation
#endif
#ifdef REDMAC_PERFORMANCE
- macTxStat_t txStat;
- macRxStat_t rxStat;
+ PfmTxMsg_t txStat;
+ PfmRxMsg_t rxStat;
#endif
/**************** Module Global Constants *****************/
enum {
-
+/*
BYTE_TIME=21, // byte at 23405 kBit/s, 4b6b encoded
PREAMBLE_BYTE_TIME=14, // byte at 23405 kBit/s, no coding
PHY_HEADER_TIME=84, // 6 Phy Preamble at 23405 bits/s
TIME_CORRECTION=16, // difference between txSFD and rxSFD: 475us
-
+*/
+ BYTE_TIME=14, // byte at 35108 kBit/s, 4b6b encoded
+ PREAMBLE_BYTE_TIME=9, // byte at 35108 kBit/s, no coding
+ PHY_HEADER_TIME=56, // 6 Phy Preamble at 35108 bits/s
+ TIME_CORRECTION=11, // difference between txSFD and rxSFD: to do
+
SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc
// DEFAULT_SLEEP_TIME=1625,
- // DEFAULT_SLEEP_TIME=3250,
- // DEFAULT_SLEEP_TIME=6500,
+ // DEFAULT_SLEEP_TIME=2048,
+ // DEFAULT_SLEEP_TIME=4096,
// DEFAULT_SLEEP_TIME=8192,
- // DEFAULT_SLEEP_TIME=16384,
- DEFAULT_SLEEP_TIME=32768U,
+ DEFAULT_SLEEP_TIME=16384,
+ // DEFAULT_SLEEP_TIME=32768U,
// DEFAULT_SLEEP_TIME=65535U,
DATA_DETECT_TIME=17,
RX_SETUP_TIME=102, // time to set up receiver
TX_GAP_TIME = RX_ACK_TIMEOUT + TX_SETUP_TIME + 33,
// the duration of a send ACK
ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
- MAX_SHORT_RETRY=9,
- MAX_LONG_RETRY=3,
+ NAV_FACTOR = 4,
+#ifndef MAC_EVAL
+ MAX_SHORT_RETRY=3,
+ MAX_LONG_RETRY=7,
+ ADD_NAV = 2,
+ INCREASE_BACKOFF = TRUE,
+#endif
TOKEN_ACK_FLAG = 64,
TOKEN_ACK_MASK = 0x3f,
INVALID_SNR = 0xffff,
// reduced minimal backoff
ZERO_BACKOFF_MASK = 0xff
};
-
+
+#ifdef MAC_EVAL
+ uint8_t MAX_SHORT_RETRY = 9;
+ uint8_t MAX_LONG_RETRY = 3;
+ uint8_t ADD_NAV = 4;
+ bool INCREASE_BACKOFF = TRUE;
+#endif
+#ifdef DELTATIMEDEBUG
+ DeltaTrace_t dTrace;
+#endif
/**************** Module Global Variables *****************/
/* flags */
typedef enum {
uint32_t backoff(uint8_t counter) {
uint32_t rVal = call Random.rand16() & MIN_BACKOFF_MASK;
+ if(!INCREASE_BACKOFF) counter = 1;
return (rVal << counter) + ZERO_BACKOFF_MASK;
}
}
uint32_t calcGeneratedTime(red_mac_header_t *m) {
- return rxTime - m->time - TIME_CORRECTION;
+ uint32_t lt = rxTime - m->time - TIME_CORRECTION;
+#ifdef DELTATIMEDEBUG
+ dTrace.now = rxTime;
+ dTrace.msgTime = lt;
+ dTrace.delta = m->time;
+ call DeltaTrace.traceRx(&dTrace);
+#endif
+ return lt;
}
/**************** Init ************************/
#endif
// sdDebug(194);
storeStrength(msg);
+#ifdef DELTATIMEDEBUG
+ dTrace.sender = getHeader(msg)->src;
+#endif
getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload);
getMetadata(msg)->ack = WAS_NOT_ACKED;
m = signal MacReceive.receiveDone(msg);
else if(action == SLEEP) {
macState = SLEEP;
if(isFlagSet(&flags, RESUME_BACKOFF)) {
+ nav = nav*(uint32_t)ADD_NAV/(uint32_t)NAV_FACTOR;
if(nav > restLaufzeit) restLaufzeit += nav;
}
else {
async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {
if((macState == TX) && (p_msg == txBufPtr)) {
+#ifdef DELTATIMEDEBUG
+ dTrace.now = call LocalTime32kHz.get();
+ dTrace.msgTime = getMetadata(p_msg)->time;
+ dTrace.delta = call TimeDiff32.computeDelta(dTrace.now, dTrace.msgTime);
+ txMacHdr->time = dTrace.delta;
+ call DeltaTrace.traceTx(&dTrace);
+#else
txMacHdr->time =
call TimeDiff32.computeDelta(call LocalTime32kHz.get(), getMetadata(p_msg)->time);
+#endif
}
}
default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
- /***** unused Radio Modes events **************************/
+ /***** Mac Eval *******************************************/
+#ifdef MAC_EVAL
+ async command void MacEval.setBackoffMask(uint16_t mask) {
+ atomic MIN_BACKOFF_MASK = mask;
+ }
+ async command void MacEval.increaseBackoff(bool value) {
+ atomic INCREASE_BACKOFF = value;
+ }
+ async command void MacEval.addNav(bool value) {
+ atomic ADD_NAV = value;
+ }
+ async command void MacEval.setLongRetry(uint8_t lr) {
+ atomic MAX_LONG_RETRY = lr;
+ }
+ async command void MacEval.setShortRetry(uint8_t sr) {
+ atomic MAX_SHORT_RETRY = sr;
+ }
+#endif
+ /***** unused Radio Modes events **************************/
async event void RadioModes.TimerModeDone() {}
async event void RadioModes.SelfPollingModeDone() {}
async event void RadioModes.PWDDDInterrupt() {}
interface Packet;
interface Sleeptime;
interface ChannelCongestion;
+#ifdef MAC_EVAL
+ interface MacEval;
+#endif
}
uses {
interface StdControl as CcaStdControl;
interface GeneralIO as Led0;
interface GeneralIO as Led1;
interface GeneralIO as Led2;
- interface GeneralIO as Led3;
-*/
+ interface GeneralIO as Led3;
+*/
+
#ifdef SPECKMAC_DEBUG
interface SerialDebug;
#endif
/**************** Module Global Constants *****************/
enum {
-
+/*
BYTE_TIME=21, // byte at 23405 kBit/s, 4b6b encoded
PREAMBLE_BYTE_TIME=14, // byte at 23405 kBit/s, no coding
PHY_HEADER_TIME=84, // 6 Phy Preamble at 23405 bits/s
TIME_CORRECTION=16, // difference between txSFD and rxSFD: 475us
+*/
+ BYTE_TIME=14, // byte at 35108 kBit/s, 4b6b encoded
+ PREAMBLE_BYTE_TIME=9, // byte at 35108 kBit/s, no coding
+ PHY_HEADER_TIME=56, // 6 Phy Preamble at 35108 bits/s
+ TIME_CORRECTION=11, // difference between txSFD and rxSFD: to do
SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc
- // DEFAULT_SLEEP_TIME=1625,
+ DEFAULT_SLEEP_TIME=1625,
// DEFAULT_SLEEP_TIME=3250,
// DEFAULT_SLEEP_TIME=6500,
// DEFAULT_SLEEP_TIME=8192,
// DEFAULT_SLEEP_TIME=16384,
- DEFAULT_SLEEP_TIME=32768U,
+ // DEFAULT_SLEEP_TIME=32768U,
// DEFAULT_SLEEP_TIME=65535U,
DATA_DETECT_TIME=17,
RX_SETUP_TIME=102, // time to set up receiver
TX_GAP_TIME = RX_ACK_TIMEOUT + TX_SETUP_TIME + 33,
// the duration of a send ACK
ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
+ NAV_FACTOR = 4,
+#ifndef MAC_EVAL
MAX_SHORT_RETRY=9,
MAX_LONG_RETRY=3,
+ ADD_NAV = 4,
+ INCREASE_BACKOFF = TRUE,
+#endif
TOKEN_ACK_FLAG = 64,
TOKEN_ACK_MASK = 0x3f,
INVALID_SNR = 0xffff,
ZERO_BACKOFF_MASK = 0xff
};
- /**************** Module Global Variables *****************/
+ /**************** Module Global Variables *****************/
+#ifdef MAC_EVAL
+ uint8_t MAX_SHORT_RETRY = 9;
+ uint8_t MAX_LONG_RETRY = 3;
+ uint8_t ADD_NAV = 4;
+ bool INCREASE_BACKOFF = TRUE;
+#endif
/* flags */
typedef enum {
SWITCHING = 1,
void setRxMode() {
setFlag(&flags, SWITCHING);
clearFlag(&flags, RSSI_STABLE);
- // sdDebug(10);
checkCounter = 0;
rssiValue = INVALID_SNR;
if(call RadioModes.RxMode() == FAIL) {
}
void setSleepMode() {
- // sdDebug(20);
clearFlag(&flags, RSSI_STABLE);
post ReleaseAdcTask();
setFlag(&flags, SWITCHING);
void setTxMode() {
post ReleaseAdcTask();
- // sdDebug(30);
clearFlag(&flags, RSSI_STABLE);
setFlag(&flags, SWITCHING);
if(call RadioModes.TxMode() == FAIL) {
void checkSend() {
if((shortRetryCounter) && (txBufPtr != NULL) && (isFlagSet(&flags, MESSAGE_PREPARED)) &&
(macState == SLEEP) && (!isFlagSet(&flags, RESUME_BACKOFF)) && (!call Timer.isRunning())) {
- // sdDebug(40);
macState = CCA;
checkCounter = 0;
setRxMode();
}
-/* else {
- if(txBufPtr) // sdDebug(41);
- if(shortRetryCounter) // sdDebug(42);
- if(isFlagSet(&flags, MESSAGE_PREPARED)) // sdDebug(43);
- if(txBufPtr) {
- if(macState == SLEEP) // sdDebug(44);
- if(!isFlagSet(&flags, RESUME_BACKOFF)) // sdDebug(45);
- if(!call Timer.isRunning()) // sdDebug(46);
- }
- }
-*/
}
uint32_t backoff(uint8_t counter) {
uint32_t rVal = call Random.rand16() & MIN_BACKOFF_MASK;
+ if(!INCREASE_BACKOFF) counter = 1;
return (rVal << counter) + ZERO_BACKOFF_MASK;
}
txMacHdr = macHdr;
setFlag(&flags, MESSAGE_PREPARED);
if(macState == SLEEP) {
- sdDebug(400);
} else {
- sdDebug(401);
}
if(!call Timer.isRunning()) {
- sdDebug(402);
} else {
- sdDebug(403);
}
if(!isFlagSet(&flags, RESUME_BACKOFF)) {
- sdDebug(404);
} else {
- sdDebug(405);
}
if((macState == SLEEP) && (!call Timer.isRunning()) && (!isFlagSet(&flags, RESUME_BACKOFF))) {
if((longRetryCounter == 1) &&
(getHeader(msg)->dest != AM_BROADCAST_ADDR)) {
call Timer.start((call Random.rand16() >> 3) & ZERO_BACKOFF_MASK);
- sdDebug(406);
}
else {
call Timer.start(backoff(longRetryCounter));
- sdDebug(407);
}
}
#ifdef SPECKMAC_PERFORMANCE
void signalSendDone(error_t error) {
message_t *m;
error_t e = error;
- // sdDebug(50);
atomic {
m = txBufPtr;
txBufPtr = NULL;
clearFlag(&flags, MESSAGE_PREPARED);
clearFlag(&flags, CANCEL_SEND);
}
- // sdDebug(3000 + e);
- // sdDebug(4000 + getHeader(m)->type);
signal MacSend.sendDone(m, e);
#ifdef SPECKMAC_PERFORMANCE
txStat.success = e;
longRetryCounter++;
shortRetryCounter = 1;
if(longRetryCounter > MAX_LONG_RETRY) {
- // sdDebug(60);
signalSendDone(FAIL);
}
}
longRetryCounter++;
shortRetryCounter = 1;
if(longRetryCounter > MAX_LONG_RETRY) {
- // sdDebug(70);
signalSendDone(FAIL);
} else {
post PrepareMsgTask();
if(call Timer.isRunning()) {
restLaufzeit = call TimeDiff16.computeDelta(call Timer.getAlarm(), call Timer.getNow());
call Timer.stop();
- sdDebug(10);
- sdDebug(restLaufzeit);
if(restLaufzeit > MIN_BACKOFF_MASK << MAX_LONG_RETRY) {
restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
}
- sdDebug(11);
- sdDebug(restLaufzeit);
setFlag(&flags, RESUME_BACKOFF);
}
}
if(!isFlagSet(&flags, RESUME_BACKOFF)) {
setFlag(&flags, RESUME_BACKOFF);
restLaufzeit = backoff(longRetryCounter);
- sdDebug(20);
- sdDebug(restLaufzeit);
updateRetryCounters();
}
}
/**************** SplitControl *****************/
task void StartDoneTask() {
- // sdDebug(90);
atomic {
call SampleTimer.start(localSleeptime);
macState = SLEEP;
+ sdDebug(60);
}
signal SplitControl.startDone(SUCCESS);
}
atomic {
macState = INIT;
setRxMode();
- // sdDebug(100);
}
+ sdDebug(10);
return SUCCESS;
}
task void StopDoneTask() {
call Init.init();
- // sdDebug(110);
signal SplitControl.stopDone(SUCCESS);
}
atomic {
if((macState == SLEEP) && isFlagSet(&flags, SWITCHING)) {
macState = STOP;
- // sdDebug(120);
}
else {
macState = STOP;
setSleepMode();
- // sdDebug(121);
}
}
return SUCCESS;
setFlag(&flags, RSSI_STABLE);
if((macState == RX) || (macState == CCA)) {
call Timer.start(DATA_DETECT_TIME);
- // sdDebug(130);
}
else if(macState == RX_P) {
- // sdDebug(131);
if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
}
else if(macState == RX_ACK) {
// if(call RssiAdcResource.isOwner()) call ChannelMonitor.start();
- // sdDebug(132);
}
else if(macState == RX_ACK_P) {
}
else if(macState == INIT) {
- // sdDebug(133);
if(call RssiAdcResource.isOwner()) {
+ sdDebug(20);
call ChannelMonitorControl.updateNoiseFloor();
} else {
+ sdDebug(21);
call RssiAdcResource.request();
}
}
else if(macState == STOP) {
- // sdDebug(134);
}
else {
- // sdDebug(135);
}
}
clearFlag(&flags, SWITCHING);
if((macState == RX) || (macState == RX_ACK) || (macState == CCA) ||
(macState == INIT) || (macState == STOP)) {
- // sdDebug(140);
if(macState != RX_ACK) requestAdc();
}
else {
- // sdDebug(141);
}
}
}
async event void RadioModes.TxModeDone() {
- // sdDebug(150);
atomic {
clearFlag(&flags, SWITCHING);
if(macState == TX) {
setFlag(&flags, ACTION_DETECTED);
if(call PacketSend.send(txBufPtr, txLen) == SUCCESS) {
- // sdDebug(151);
}
else {
- // sdDebug(152);
}
}
else if(macState == TX_ACK) {
if(call PacketSend.send(&ackMsg, 0) == SUCCESS) {
- // sdDebug(153);
} else {
- // sdDebug(154);
}
}
else {
- // sdDebug(155);
}
}
}
async event void RadioModes.SleepModeDone() {
- // sdDebug(160);
atomic {
clearFlag(&flags, SWITCHING);
if(isFlagSet(&flags, ACTION_DETECTED)) {
} else {
if(congestionLevel > 0) congestionLevel--;
}
- // if(congestionLevel > 3) // sdDebug(2000 + congestionLevel);
if(macState == SLEEP) {
- // sdDebug(161);
if(!call Timer.isRunning()) {
- // sdDebug(162);
if(isFlagSet(&flags, RESUME_BACKOFF)) {
- // sdDebug(164);
clearFlag(&flags, RESUME_BACKOFF);
call Timer.start(restLaufzeit);
restLaufzeit = 0;
- sdDebug(30);
}
else {
- // sdDebug(165);
checkSend();
}
}
}
else if(macState == STOP) {
- // sdDebug(168);
post StopDoneTask();
}
signal ChannelCongestion.congestionEvent(congestionLevel);
atomic {
if((shortRetryCounter == 0) && (txBufPtr == NULL)) {
clearFlag(&flags, MESSAGE_PREPARED);
- // sdDebug(5000 + getHeader(msg)->type);
shortRetryCounter = 1;
longRetryCounter = 1;
txBufPtr = msg;
#endif
}
else {
- // sdDebug(171);
err = EBUSY;
}
}
if(err == SUCCESS) {
- sdDebug(300);
post PrepareMsgTask();
}
return err;
error_t err = FAIL;
atomic {
if(msg == txBufPtr) {
- // sdDebug(320);
setFlag(&flags, CANCEL_SEND);
shortRetryCounter = MAX_SHORT_RETRY + 2;
longRetryCounter = MAX_LONG_RETRY + 2;
if(macState == SLEEP) {
- // sdDebug(321);
signalSendDone(ECANCEL);
}
else {
- // sdDebug(322);
}
- // sdDebug(1000 + macState);
err = SUCCESS;
}
else {
- // sdDebug(323);
- // sdDebug(1100 + macState);
}
}
return err;
call ChannelMonitor.rxSuccess();
if(macState <= CCA_ACK) {
if(macState == CCA) {
- sdDebug(100);
computeBackoff();
#ifdef SPECKMAC_PERFORMANCE
call Performance.macDetectedOnCca();
if(macState != RX_ACK) {
macState = RX_P;
} else {
- sdDebug(500);
macState = RX_ACK_P;
}
}
else if(macState == INIT) {
- // sdDebug(180);
setFlag(&flags, UNHANDLED_PACKET);
}
}
rxStat.duplicate = PERF_UNKNOWN;
rxStat.repCounter = 0xff;
#endif
- // sdDebug(190);
if(macState == RX_P) {
- // sdDebug(191);
if(error == SUCCESS) {
- // sdDebug(192);
isCnt = isControl(msg);
if(msgIsForMe(msg)) {
if(!isCnt) {
- // sdDebug(193);
if(isNewMsg(msg)) {
#ifdef SPECKMAC_PERFORMANCE
rxStat.duplicate = PERF_NEW_MSG;
// assume a buffer swap -- if buffer is not swapped, assume that the
// message was not successfully delivered to upper layers
if(m != msg) {
- // sdDebug(195);
rememberMsg(msg);
} else {
- // sdDebug(196);
action = RX;
#ifdef SPECKMAC_PERFORMANCE
call Performance.macQueueFull();
}
#endif
if(needsAckRx(msg) && (action != RX)) {
- // sdDebug(197);
if(((red_mac_header_t*)payload)->repetitionCounter == 0) {
action = CCA_ACK;
}
}
}
else {
- // sdDebug(198);
if(action != RX) {
nav = ((red_mac_header_t*)payload)->repetitionCounter *
(SUB_HEADER_TIME + getHeader(msg)->length*BYTE_TIME +
}
}
else {
- // sdDebug(199);
action = RX;
}
}
else {
- // sdDebug(200);
action = SLEEP;
if(!isCnt) {
nav = ((red_mac_header_t*)payload)->repetitionCounter *
}
}
else {
- // sdDebug(201);
action = SLEEP;
}
}
else if(macState == RX_ACK_P) {
if(error == SUCCESS) {
if(ackIsForMe(msg)) {
- sdDebug(510);
storeStrength(msg);
getMetadata(txBufPtr)->ack = WAS_ACKED;
getMetadata(txBufPtr)->repetitions = txMacHdr->repetitionCounter;
- // sdDebug(203);
signalSendDone(SUCCESS);
- // sdDebug(30000 + getHeader(msg)->src);
action = SLEEP;
}
else {
- sdDebug(511);
updateLongRetryCounters(); // this will eventually schedule the right backoff
macState = SLEEP; // so much traffic is going on -- take a nap
setSleepMode();
}
else {
if(call Timer.isRunning()) {
- sdDebug(512);
action = RX_ACK;
}
else {
- sdDebug(513);
updateLongRetryCounters();
action = RX;
}
}
}
else {
- // sdDebug(206);
action = INIT;
}
if(action == CCA_ACK) {
macState = SLEEP;
if(isFlagSet(&flags, RESUME_BACKOFF)) {
if(nav > restLaufzeit) {
- sdDebug(40);
- sdDebug(restLaufzeit);
- restLaufzeit += nav;
+ if(nav > restLaufzeit) restLaufzeit += ((uint32_t)ADD_NAV*nav/NAV_FACTOR);
}
- sdDebug(41);
- sdDebug(restLaufzeit);
}
else {
setFlag(&flags, RESUME_BACKOFF);
restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
- sdDebug(42);
- sdDebug(restLaufzeit);
}
setSleepMode();
}
clearFlag(&flags, UNHANDLED_PACKET);
}
else {
- // sdDebug(207);
}
#ifdef SPECKMAC_PERFORMANCE
if(error == SUCCESS) {
macState = RX_ACK;
setRxMode();
call Timer.start(RX_ACK_TIMEOUT);
- // sdDebug(220);
checkCounter = 0;
}
}
checkCounter = 0;
macState = RX;
setRxMode();
- // sdDebug(221);
-#ifdef SPECKMAC_DEBUG
- // sdDebug(40000U + repCounter);
+#ifdef SPECKMAC_DEBUG
#endif
}
}
setFlag(&flags, ACTION_DETECTED);
if((macState == RX) || (macState == CCA) || (macState == CCA_ACK)) {
if(macState == CCA) {
- sdDebug(101);
computeBackoff();
#ifdef SPECKMAC_PERFORMANCE
call Performance.macBusyOnCca();
#endif
}
requestAdc();
- // sdDebug(230);
macState = RX;
checkCounter = 0;
call Timer.start(TX_GAP_TIME>>1);
void checkOnIdle() {
if(macState == RX) {
- // sdDebug(240);
checkCounter++;
if(checkCounter < 2) {
call Timer.start(DATA_DETECT_TIME);
else if(macState == CCA) {
checkCounter++;
if(checkCounter < 3) {
- // sdDebug(242);
call Timer.start(TX_GAP_TIME >> 1);
requestAdc();
}
else {
- // sdDebug(243);
macState = TX;
setTxMode();
#ifdef SPECKMAC_PERFORMANCE
}
async event void Timer.fired() {
- // sdDebug(250);
if((macState == RX) || (macState == CCA) || (macState == CCA_ACK)) {
if((!call RssiAdcResource.isOwner()) || (call ChannelMonitor.start() != SUCCESS)) {
if(call UartPhyControl.isBusy()) {
- // sdDebug(251);
checkOnBusy();
}
else {
- // sdDebug(252);
checkOnIdle();
}
}
}
else if(macState == RX_ACK) {
if(needsAckTx(txBufPtr)) {
- // sdDebug(254);
#ifdef SPECKMAC_PERFORMANCE
call Performance.macAckTimeout();
#endif
updateLongRetryCounters();
}
else {
- // sdDebug(255);
signalSendDone(SUCCESS);
}
macState = SLEEP;
}
else if(macState == TX_ACK) {
setTxMode();
- // sdDebug(10000 + getHeader(&ackMsg)->dest);
}
else if(macState == SLEEP) {
if(isFlagSet(&flags, SWITCHING)) {
- // sdDebug(256);
call Timer.start(call Random.rand16() & 0x0f);
}
else {
if(isFlagSet(&flags, RESUME_BACKOFF)) {
- // sdDebug(261);
clearFlag(&flags, RESUME_BACKOFF);
call Timer.start(restLaufzeit);
restLaufzeit = 0;
- sdDebug(50);
}
else {
- // sdDebug(262);
checkSend();
}
}
}
else if((macState == RX_ACK_P) || (macState == RX_P)) {
- // sdDebug(258);
}
else if(macState == INIT) {
- // sdDebug(259);
post StartDoneTask();
+ sdDebug(50);
}
else {
- // sdDebug(260);
}
}
async event void SampleTimer.fired() {
call SampleTimer.start(localSleeptime);
- // sdDebug(270);
if((macState == SLEEP) && (!isFlagSet(&flags, SWITCHING))) {
clearFlag(&flags, ACTION_DETECTED);
- sdDebug(200);
interruptBackoffTimer();
macState = RX;
- // sdDebug(271);
setRxMode();
call Timer.stop();
}
/****** ChannelMonitor events *********************/
async event void ChannelMonitor.channelBusy() {
- // sdDebug(280);
checkOnBusy();
}
async event void ChannelMonitor.channelIdle() {
- // sdDebug(281);
checkOnIdle();
}
event void ChannelMonitorControl.updateNoiseFloorDone() {
if(macState == INIT) {
- // sdDebug(290);
call Timer.start(call Random.rand16() % localSleeptime);
setSleepMode();
+ sdDebug(40);
} else {
- // sdDebug(291);
}
}
macState_t ms;
atomic ms = macState;
if(ms < SLEEP) {
- // sdDebug(300);
}
else if(ms == INIT) {
- // sdDebug(301);
+ sdDebug(30);
call ChannelMonitorControl.updateNoiseFloor();
}
else {
- // sdDebug(302);
post ReleaseAdcTask();
}
}
+ /***** Mac Eval *******************************************/
+#ifdef MAC_EVAL
+ async command void MacEval.setBackoffMask(uint16_t mask) {
+ atomic MIN_BACKOFF_MASK = mask;
+ }
+ async command void MacEval.increaseBackoff(bool value) {
+ atomic INCREASE_BACKOFF = value;
+ }
+ async command void MacEval.addNav(bool value) {
+ atomic ADD_NAV = value;
+ }
+ async command void MacEval.setLongRetry(uint8_t lr) {
+ atomic MAX_LONG_RETRY = lr;
+ }
+ async command void MacEval.setShortRetry(uint8_t sr) {
+ atomic MAX_SHORT_RETRY = sr;
+ }
+#endif
+
+ /***** unused events **************************/
default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
/***** unused Radio Modes events **************************/