[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip WakeupComm.h, NONE, 1.1 WakeupCommC.nc, NONE, 1.1 WakeupCommM.nc, NONE, 1.1

Gilman Tolle gtolle at users.sourceforge.net
Tue Apr 26 19:48:46 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/Drip
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14760

Added Files:
	WakeupComm.h WakeupCommC.nc WakeupCommM.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.

--- NEW FILE: WakeupComm.h ---
enum {
  WAKE_PERIOD = 1024,
  WAKE_LENGTH = 64,
};

--- NEW FILE: WakeupCommC.nc ---
includes WakeupComm;

configuration WakeupCommC {
  provides interface SendMsg[uint8_t id];
}
implementation {
  components WakeupCommM, GenericComm, TimerC;
  
  SendMsg = WakeupCommM.WakeupSendMsg;

  WakeupCommM.Timer -> TimerC.Timer[unique("Timer")];
  WakeupCommM.SendMsg -> GenericComm;
}

--- NEW FILE: WakeupCommM.nc ---
module WakeupCommM {
  provides interface SendMsg as WakeupSendMsg[uint8_t id];
  uses interface SendMsg[uint8_t id];
  uses interface Timer;
}
implementation {

  bool busy;
  uint8_t sendCount;
  uint16_t address;
  uint8_t length;
  uint8_t id;
  TOS_MsgPtr msg;
  
  command result_t WakeupSendMsg.send[uint8_t _id](uint16_t _address, 
						   uint8_t _length, 
						   TOS_MsgPtr _msg) {

    if (busy)
      return FAIL;
    busy = TRUE;
    sendCount = 0;

    address = _address; length = _length; msg = _msg; id = _id;
    return call Timer.start(TIMER_REPEAT, WAKE_LENGTH);
  }

  event result_t Timer.fired() {

    if (sendCount >= WAKE_PERIOD / WAKE_LENGTH) {
      call Timer.stop();
      signal WakeupSendMsg.sendDone[id](msg, SUCCESS);
      busy = FALSE;
      return SUCCESS;
    }

    call SendMsg.send[id](address, length, msg);
    return SUCCESS;
  }

  event result_t SendMsg.sendDone[uint8_t _id](TOS_MsgPtr _msg, 
					       result_t _success) {
    if (msg == _msg && _success) {
      sendCount++;
    }
    return SUCCESS;
  }

  default event result_t WakeupSendMsg.sendDone[uint8_t _id](TOS_MsgPtr _msg, 
							     result_t _success) {
    return SUCCESS;
  }
}



More information about the Tinyos-beta-commits mailing list