Hi,

I'm trying to bridge packets from serial to radio in tinyos1. I'm able
to send packets to the mote via UART. I'm also able to use the
GenericComm component and SendMsg interface to send radio packets. But
when I try to club the 2 functionalities, i.e. send the packet
received by UART signalled by the interface UartTokenReceive over the
radio using SendMsg implemented by GenericComm, the send command
doesn't go through. Infact, the UartTokenReceive event is also not
signalled when the radio send functionality is added.

Is this because the GenericComm and FramerM components can't be used
simultaneously? I just can't figure out the problem and it would be
great if somebody can help me out.

The code is:

#include "UARTMsg.h"
#include "RADIOMsg.h"

module PCToMoteRadioM{
        provides interface StdControl;
        uses{
                interface Leds;
                interface StdControl as UARTControl;
                interface StdControl as RadioControl;
            interface BareSendMsg as UARTSend;
                interface ReceiveMsg as UARTReceive;
                interface TokenReceiveMsg as UARTTokenReceive;
                interface SendMsg;
        }
}

implementation{
        struct UARTMsg * pc_msg;
        RadioMsg * mote_radio;
        TOS_Msg to_radio;

        command result_t StdControl.init() {
                call UARTControl.init();
                call Leds.init();

                return SUCCESS;
        }

        command result_t StdControl.start() {
                call UARTControl.start();

                return SUCCESS;
        }

        command result_t StdControl.stop() {
                call UARTControl.stop();

                return SUCCESS;
        }
        
        event TOS_MsgPtr UARTReceive.receive(TOS_MsgPtr Msg) {
                call Leds.set(2);
                return Msg;
        }

        event TOS_MsgPtr UARTTokenReceive.receive(TOS_MsgPtr Msg, uint8_t 
Token) {
                call Leds.set(1);
                /*pc_msg = (struct UARTMsg *) Msg->data;
                mote_radio = (RadioMsg *) to_radio.data;
                mote_radio->count = pc_msg->count;
                if(call SendMsg.send(TOS_BCAST_ADDR, sizeof(RadioMsg), 
&to_radio) == SUCCESS){
                        call Leds.set(pc_msg->count);
                }*/
                
                return Msg;
        }
        
        event result_t UARTSend.sendDone(TOS_MsgPtr msg, result_t success) {
            return SUCCESS;
        }
        
        event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success){
                return success;
        }
}

----------------------------------------------------------------------------------------------------------------------------------------------
#include "UARTMsg.h"
#include "RadioMsg.h"

configuration PCToMoteRadioC{
}

implementation{
        components Main, PCToMoteRadioM, FramerM, UART, LedsC, GenericComm;

        Main.StdControl -> PCToMoteRadioM;
        PCToMoteRadioM.UARTControl -> FramerM;
        PCToMoteRadioM.UARTSend -> FramerM;
        PCToMoteRadioM.UARTReceive -> FramerM;
        PCToMoteRadioM.UARTTokenReceive -> FramerM;

        Main.StdControl -> GenericComm;
        PCToMoteRadioM.SendMsg -> GenericComm.SendMsg[AM_RADIOMSG];
        
        PCToMoteRadioM.Leds -> LedsC;
        
        FramerM.ByteControl -> UART;
        FramerM.ByteComm -> UART;
}

Thanks,

Bhavish
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to