[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip Drip.h, 1.1,
1.2 DripC.nc, 1.2, 1.3 DripM.nc, 1.2, 1.3 DripStateM.nc, 1.1, 1.2
Gilman Tolle
gtolle at users.sourceforge.net
Tue Apr 26 19:48:28 PDT 2005
Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14669
Modified Files:
Drip.h DripC.nc DripM.nc DripStateM.nc
Log Message:
Added support for a wakeup bit in the Drip message. The last bit of the sequence number is the wakeup bit. When the bit is set, the message is rebroadcast multiple times, to wake up a sleeping node. This technique allows any Drip message to wake up a sleeping network.
Index: Drip.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/Drip.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Drip.h 19 Jan 2005 00:01:16 -0000 1.1
--- Drip.h 27 Apr 2005 02:48:26 -0000 1.2
***************
*** 62,65 ****
--- 62,66 ----
DRIP_SEQNO_OLDEST = 0xff,
DRIP_SEQNO_NEWEST = 0,
+ DRIP_SEQNO_FIRST = 2,
DRIP_TIMER_PERIOD = 1024,
DRIP_MIN_SEND_INTERVAL = 0,
***************
*** 67,70 ****
--- 68,72 ----
DRIP_PRE_SEND = 0,
DRIP_POST_SEND = 1,
+ DRIP_WAKEUP_BIT = 0x1,
};
Index: DripC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/DripC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DripC.nc 2 Feb 2005 05:30:57 -0000 1.2
--- DripC.nc 27 Apr 2005 02:48:26 -0000 1.3
***************
*** 45,48 ****
--- 45,49 ----
DripStateC,
GenericComm as Comm,
+ WakeupCommC,
TimerC,
RandomLFSR,
***************
*** 63,66 ****
--- 64,69 ----
DripM.SendMsg -> Comm.SendMsg[AM_DRIPMSG];
+ DripM.WakeupSendMsg -> WakeupCommC.SendMsg[AM_DRIPMSG];
+
DripM.SendTimer -> TimerC.Timer[unique("Timer")];
Index: DripM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/DripM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** DripM.nc 17 Feb 2005 01:12:20 -0000 1.2
--- DripM.nc 27 Apr 2005 02:48:26 -0000 1.3
***************
*** 49,52 ****
--- 49,55 ----
interface ReceiveMsg;
interface SendMsg;
+
+ interface SendMsg as WakeupSendMsg;
+
interface Timer as SendTimer;
interface Random;
***************
*** 133,140 ****
call DripState.fillMetadata[id](&dripMsg->metadata);
!
! result = call SendMsg.send(TOS_BCAST_ADDR,
! offsetof(DripMsg,data) + len,
! pMsgBuf);
if (result == SUCCESS) {
--- 136,149 ----
call DripState.fillMetadata[id](&dripMsg->metadata);
!
! if (dripMsg->metadata.seqno & DRIP_WAKEUP_BIT) {
! result = call WakeupSendMsg.send(TOS_BCAST_ADDR,
! offsetof(DripMsg,data) + len,
! pMsgBuf);
! } else {
! result = call SendMsg.send(TOS_BCAST_ADDR,
! offsetof(DripMsg,data) + len,
! pMsgBuf);
! }
if (result == SUCCESS) {
***************
*** 159,162 ****
--- 168,183 ----
}
+ event result_t WakeupSendMsg.sendDone(TOS_MsgPtr pMsg,
+ result_t success) {
+
+ if (pMsg == &msgBuf &&
+ msgBufBusy == TRUE) {
+
+ msgBufBusy = FALSE;
+ }
+
+ return SUCCESS;
+ }
+
event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr pMsg) {
Index: DripStateM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/Drip/DripStateM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** DripStateM.nc 19 Jan 2005 00:01:18 -0000 1.1
--- DripStateM.nc 27 Apr 2005 02:48:26 -0000 1.2
***************
*** 38,42 ****
dripEntry->metadata.id = globalKey;
! dripEntry->metadata.seqno = 1;
trickleReset(dripEntry);
--- 38,42 ----
dripEntry->metadata.id = globalKey;
! dripEntry->metadata.seqno = DRIP_SEQNO_FIRST;
trickleReset(dripEntry);
***************
*** 56,60 ****
DripCacheEntry *dripEntry = &dripCache[localKey];
! if (seqno != DRIP_SEQNO_OLDEST && seqno != DRIP_SEQNO_NEWEST) {
dripEntry->metadata.seqno = seqno;
return SUCCESS;
--- 56,62 ----
DripCacheEntry *dripEntry = &dripCache[localKey];
! uint8_t trueSeqno = seqno & ~DRIP_WAKEUP_BIT;
!
! if (trueSeqno != DRIP_SEQNO_OLDEST && trueSeqno != DRIP_SEQNO_NEWEST) {
dripEntry->metadata.seqno = seqno;
return SUCCESS;
***************
*** 76,84 ****
void incrementSeqno(DripCacheEntry *dripEntry) {
dripEntry->metadata.seqno++;
// Seqno 0 means that the seqno is unknown, and should only be seen
// in a message coming in from the UART.
! while (dripEntry->metadata.seqno == DRIP_SEQNO_OLDEST ||
! dripEntry->metadata.seqno == DRIP_SEQNO_NEWEST) {
dripEntry->metadata.seqno++;
}
--- 78,88 ----
void incrementSeqno(DripCacheEntry *dripEntry) {
dripEntry->metadata.seqno++;
+ dripEntry->metadata.seqno++;
// Seqno 0 means that the seqno is unknown, and should only be seen
// in a message coming in from the UART.
! while ((dripEntry->metadata.seqno & ~DRIP_WAKEUP_BIT) == DRIP_SEQNO_OLDEST ||
! (dripEntry->metadata.seqno & ~DRIP_WAKEUP_BIT) == DRIP_SEQNO_NEWEST) {
! dripEntry->metadata.seqno++;
dripEntry->metadata.seqno++;
}
***************
*** 93,122 ****
command bool DripState.newMsg[uint8_t localKey](DripMetadata incomingMetadata) {
-
DripCacheEntry *dripEntry = &dripCache[localKey];
! /* Avoid the situation in which the sequence numbers both think their
! neighbor is less. */
!
! /*
! if ((int8_t)((int8_t)incomingMetadata.seqno - (int8_t)dripEntry->metadata.seqno) == -128
! && dripEntry->metadata.seqno > 0) {
!
! incrementSeqno(dripEntry);
! }
! */
!
! if (incomingMetadata.seqno != DRIP_SEQNO_OLDEST &&
! ((int8_t)(incomingMetadata.seqno - dripEntry->metadata.seqno) > 0 ||
! incomingMetadata.seqno == DRIP_SEQNO_NEWEST)) {
/* my entry is older. save new data. */
! if (incomingMetadata.seqno == DRIP_SEQNO_NEWEST) {
/* It's coming in from outside, and does not know the seqno.
Give it an incremented seqno. */
!
incrementSeqno(dripEntry);
} else {
--- 97,126 ----
command bool DripState.newMsg[uint8_t localKey](DripMetadata incomingMetadata) {
DripCacheEntry *dripEntry = &dripCache[localKey];
! uint8_t incomingSeqno = incomingMetadata.seqno & ~DRIP_WAKEUP_BIT;
! uint8_t currentSeqno = dripEntry->metadata.seqno & ~DRIP_WAKEUP_BIT;
!
! if (incomingSeqno != DRIP_SEQNO_OLDEST &&
! ((int8_t)(incomingSeqno - currentSeqno) > 0 ||
! incomingSeqno == DRIP_SEQNO_NEWEST)) {
/* my entry is older. save new data. */
! if (incomingSeqno == DRIP_SEQNO_NEWEST) {
/* It's coming in from outside, and does not know the seqno.
Give it an incremented seqno. */
!
incrementSeqno(dripEntry);
+ // if the new seqno and the current seqno are different in
+ // their wakeup status, increment the current seqno once more
+ // to make them match.
+
+ if ((dripEntry->metadata.seqno & DRIP_WAKEUP_BIT) !=
+ (incomingMetadata.seqno & DRIP_WAKEUP_BIT)) {
+ dripEntry->metadata.seqno++;
+ }
+
} else {
***************
*** 128,140 ****
return TRUE;
! } else if ((int8_t)(incomingMetadata.seqno - dripEntry->metadata.seqno) == 0 &&
! incomingMetadata.seqno != DRIP_SEQNO_OLDEST) {
/* my entry is equal. suppress. */
!
! #ifdef DRIP_NO_SUPPRESS_WAKEUP
! if (dripEntry->metadata.id != DRIP_WAKEUPID)
! #endif
! dripEntry->trickleSuppress = TRUE;
} else {
--- 132,141 ----
return TRUE;
! } else if ((int8_t)(incomingSeqno - currentSeqno) == 0 &&
! incomingSeqno != DRIP_SEQNO_OLDEST) {
/* my entry is equal. suppress. */
!
! dripEntry->trickleSuppress = TRUE;
} else {
More information about the Tinyos-beta-commits
mailing list