[Tinyos-beta-commits] CVS: tinyos-1.x/beta/Drip/TestDripSend Makefile, NONE, 1.1 TestDripSend.h, NONE, 1.1 TestDripSend.nc, NONE, 1.1 TestDripSendM.nc, NONE, 1.1

Gilman Tolle gtolle at users.sourceforge.net
Fri Jun 10 12:19:54 PDT 2005


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

Added Files:
	Makefile TestDripSend.h TestDripSend.nc TestDripSendM.nc 
Log Message:
test app for DripSend

--- NEW FILE: Makefile ---
COMPONENT=TestDripSend

PFLAGS += -I$(TOSDIR)/../beta/Drip/
PFLAGS += -I$(TOSDIR)/../contrib/nucleus/tos/lib/Nucleus

include $(TOSDIR)/../apps/Makerules

--- NEW FILE: TestDripSend.h ---
enum {
  AM_TESTDRIPMSG = 254,
};

typedef struct TestDripMsg {
  uint16_t data;
} TestDripMsg;

--- NEW FILE: TestDripSend.nc ---
includes TestDripSend;

configuration TestDripSend {

}
implementation {
  
  components 
    Main, 
    TestDripSendM,
    DripSendC,
    GroupManagerC,
    TimerC,
    LedsC as Leds;
  
  Main.StdControl -> TestDripSendM;
  Main.StdControl -> DripSendC;
  Main.StdControl -> TimerC;
  Main.StdControl -> GroupManagerC;

  TestDripSendM.Leds -> Leds;
  TestDripSendM.Timer -> TimerC.Timer[unique("Timer")];

  TestDripSendM.Send -> DripSendC;
  TestDripSendM.SendMsg -> DripSendC;
  TestDripSendM.Receive -> DripSendC;
  TestDripSendM.GroupManager -> GroupManagerC;
}

--- NEW FILE: TestDripSendM.nc ---
module TestDripSendM {
  provides interface StdControl;

  uses {
    interface Leds;

    interface Timer;

    interface Send;
    interface SendMsg;
    interface Receive;

    interface GroupManager;
  }
}

implementation {
  
  TOS_Msg msgBuf;
  uint16_t data;

  command result_t StdControl.init() { 
    call Leds.init();
    return SUCCESS; 
  }
  
  command result_t StdControl.start() { 
    if (TOS_LOCAL_ADDRESS == 1)
      call GroupManager.joinForward(0xFEFE);

    if (TOS_LOCAL_ADDRESS == 3) 
      call GroupManager.joinForward(0xFEFE);

    if (TOS_LOCAL_ADDRESS == 6) 
      call GroupManager.joinForward(0xFEFE);
    
    if (TOS_LOCAL_ADDRESS == 18)
      call GroupManager.joinGroup(0xFEFE);
    
    if (TOS_LOCAL_ADDRESS == 1) {
      call Timer.start(TIMER_REPEAT, 2048);
    }
    return SUCCESS; 
  }

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

  event result_t Timer.fired() {
    uint16_t length;
    TestDripMsg* tdMsg = (TestDripMsg*) call Send.getBuffer(&msgBuf, &length);

    data++;

    tdMsg->data = data;

    dbg(DBG_USR1, "sending data %d\n", tdMsg->data);

    call SendMsg.send(0xFEFE, sizeof(TestDripMsg), &msgBuf);

    return SUCCESS;
  }

  event TOS_MsgPtr Receive.receive(TOS_MsgPtr msg, 
				   void* payload, 
				   uint16_t payloadLen) {
    
    TestDripMsg *tdMsg = (TestDripMsg*)payload;
    data = tdMsg->data;
    call Leds.redToggle();
    dbg(DBG_USR1, "got data %d\n", data);
    return msg;
  }

  event result_t Send.sendDone(TOS_MsgPtr msg, result_t success) {
    return SUCCESS;
  }

  event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) {
    return SUCCESS;
  }
}



More information about the Tinyos-beta-commits mailing list