[Tinyos-help] Acknowledgements in Micaz

cbalasubramanian at umassd.edu cbalasubramanian at umassd.edu
Wed Nov 26 21:47:37 PST 2008


Hi,
I have a question regarding acknowledgments in micaz. I am using the
following module and calling the MacControl.disableAck(). However I am
still able to receive acks.
I was wondering how this is possible??

Thanks,
Chandrika


module MyAppM
{
  provides {
  interface StdControl;
  }
  uses {
  interface Timer;
  interface SendMsg;
  interface ReceiveMsg;
  interface Leds;
  interface MacControl;
  }
}

implementation
{
  TOS_Msg m_msg;
  int m_int;
  bool sending_packet = FALSE;

  command result_t StdControl.init() {
    m_int = 0;
    call Leds.init();
    return SUCCESS;
  }

  command result_t StdControl.start() {
	call MacControl.disableAck();
    if( TOS_LOCAL_ADDRESS == 1 ){
      call Timer.start( TIMER_REPEAT, 5000 );
	}
    return SUCCESS;
  }

  command result_t StdControl.stop() {
    return SUCCESS;
  }

  event result_t Timer.fired() {
    if( sending_packet == FALSE ) {
      CountMsg_t* body = (CountMsg_t*)m_msg.data;
      body->n = m_int;
      body->src = TOS_LOCAL_ADDRESS;
      if( call SendMsg.send( 2, sizeof(CountMsg_t), &m_msg ) == SUCCESS ) {
			call Leds.set( m_int );
			sending_packet = TRUE;
		}
    }
    //m_int++;
    return SUCCESS;
  }

  event result_t SendMsg.sendDone( TOS_MsgPtr msg, result_t success ) {
    if (msg->ack)
      m_int++;
    sending_packet = FALSE;
    return SUCCESS;
  }

  event TOS_MsgPtr ReceiveMsg.receive( TOS_MsgPtr msg ) {
	if( TOS_LOCAL_ADDRESS != 1 ){
		CountMsg_t* body = (CountMsg_t*)(&msg->data[0]);
		call Leds.set( body->n );
	}
    return msg;
  }
}





More information about the Tinyos-help mailing list