I am writing an application to bridge packets from UART to radio in
tinyos 1. The send command on the radio returns a success but the
senddone event is not signalled. Could anyone please help me with this
issue. The code is as below.

Thanks,

Bhavish

module UARTToRadioM{
        provides{
                interface StdControl;
        }
        uses{
                interface StdControl as UARTControl;
                interface ReceiveMsg as UARTReceive;
            interface BareSendMsg as UARTSend;
            interface TokenReceiveMsg as UARTTokenReceive;

                interface StdControl as RadioControl;
                interface BareSendMsg as RadioSend;
                interface ReceiveMsg as RadioReceive;

                interface Leds;
        }
}

implementation{

  void failBlink();

  command result_t StdControl.init() {
    result_t ok1, ok2, ok3;

    ok1 = call UARTControl.init();
    ok2 = call RadioControl.init();
    ok3 = call Leds.init();

    return rcombine3(ok1, ok2, ok3);
  }

  command result_t StdControl.start() {
    result_t ok1, ok2;

    ok1 = call UARTControl.start();
    ok2 = call RadioControl.start();

    return rcombine(ok1, ok2);
  }

  command result_t StdControl.stop() {
    result_t ok1, ok2;

    ok1 = call UARTControl.stop();
    ok2 = call RadioControl.stop();

    return rcombine(ok1, ok2);
  }

  event result_t UARTSend.sendDone(TOS_MsgPtr msg, result_t success) {
        if (!success) {
      failBlink();
    }

    return SUCCESS;
  }

  event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr Msg) {
        if (call RadioSend.send(&Msg) == SUCCESS) {
                call Leds.redToggle();
        }
        else{
                failBlink();
    }
        
        return Msg;
  }

  event TOS_MsgPtr UARTTokenReceive.receive(TOS_MsgPtr Msg, uint8_t Token) {
        if (call RadioSend.send(Msg) == SUCCESS) {
                call Leds.redToggle();
        }
        else{
                call Leds.redToggle();
//              failBlink();
    }
        
        return Msg;
  }

  event TOS_MsgPtr RadioReceive.receive(TOS_MsgPtr Msg) {
    if ((!Msg->crc))
      return Msg;
        
        if (call UARTSend.send(&Msg) == SUCCESS) {
                call Leds.greenToggle();
    }
        else {
                failBlink();
    }

    return Msg;
  }


  event result_t RadioSend.sendDone(TOS_MsgPtr msg, result_t success) {
    if (!success) {
         call Leds.greenToggle();
                //failBlink();
    }
    call Leds.yellowToggle();
    return SUCCESS;
  }

  void failBlink() {
    call Leds.yellowToggle();
  }
}

configuration UARTToRadioC {
}
implementation {
  components Main, UARTToRadioM, RadioCRCPacket as Comm, FramerM, UART, LedsC;

  Main.StdControl -> UARTToRadioM;

  UARTToRadioM.UARTControl -> FramerM;
  UARTToRadioM.UARTReceive -> FramerM;
  UARTToRadioM.UARTSend -> FramerM;
  UARTToRadioM.UARTTokenReceive -> FramerM;

  UARTToRadioM.RadioControl -> Comm;
  UARTToRadioM.RadioSend -> Comm;
  UARTToRadioM.RadioReceive -> Comm;

  UARTToRadioM.Leds -> LedsC;

  FramerM.ByteControl -> UART;
  FramerM.ByteComm -> UART;
}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to