1 / 8

Linear Routing

Linear Routing. Sending Message . command result_t IntOutput.output(uint16_t value) { IntMsg *message = (IntMsg *)data.data; if (!pending) { pending = TRUE; message->val = value; message->src = TOS_LOCAL_ADDRESS; if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data))

gladys
Download Presentation

Linear Routing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Linear Routing

  2. Sending Message command result_t IntOutput.output(uint16_t value) { IntMsg *message = (IntMsg *)data.data; if (!pending) { pending = TRUE; message->val = value; message->src = TOS_LOCAL_ADDRESS; if (call Send.send(TOS_BCAST_ADDR, sizeof(IntMsg), &data)) return SUCCESS; pending = FALSE; } return FAIL; }

  3. SimpleCmdMsg // SimpleCmd message structure typedef struct SimpleCmdMsg { int8_t seqno; int8_t action; uint16_t source; uint8_t hop_count; union { start_sense_args ss_args; read_log_args rl_args; uint8_t untyped_args[0]; } args; } SimpleCmdMsg; typedef struct IntMsg { uint16_t val; uint16_t src; } IntMsg;

  4. SendCmd #define ADDR_OF_MOTE 0x0001 command result_t IntOutput.output(uint16_t value) { struct SimpleCmdMsg *message = (struct SimpleCmdMsg *)data.data; if (!pending) { pending = TRUE; message->action = value; atomic { message->source = TOS_LOCAL_ADDRESS; } if (call Send.send(ADDR_OF_MOTE, sizeof(SimpleCmdMsg ), &data)) { call Leds.greenOn(); return SUCCESS; } pending = FALSE; } return FAIL; } includes SimpleCmdMsg; configuration SendCmd { provides{ interface IntOutput; interface StdControl; } } implementation { components Main, SendCmdM, GenericComm as Comm, Cdata, LedsC; IntOutput = SendCmdM; StdControl= SendCmdM; Main.StdControl -> SendCmdM; Main.StdControl -> Cdata.StdControl; SendCmdM.Leds -> LedsC; SendCmdM.Send -> Comm.SendMsg[AM_SIMPLECMDMSG]; SendCmdM.SubControl -> Comm; Cdata.IntOutput ->SendCmdM; }

  5. CData module Cdata { provides { interface StdControl; } uses { interface IntOutput; //This Interface is Provided by //SendCmdM } } command result_t StdControl.start() { if( call IntOutput.output (some_value) ) return SUCCESS; } //Here we can also write a method which can call IntOutput.output instead of doing it in Start()

  6. Receive Data event TOS_MsgPtr ReceiveCmdMsg.receive(TOS_MsgPtr pmsg){ TOS_MsgPtr ret = msg; result_t retval; call Leds.greenToggle(); retval = call ProcessCmd.execute(pmsg) ; post forwarder(); : : } includes SimpleCmdMsg; configuration RecvCmd { provides interface ProcessCmd; } implementation { components Main, RecvCmdM, SendCmd, GenericComm as Comm, LedsC; Main.StdControl -> RecvCmdM; Main.StdControl -> SendCmd; RecvCmdM.Leds -> LedsC; ProcessCmd = RecvCmdM.ProcessCmd; RecvCmdM.CommControl -> Comm; RecvCmdM.ReceiveCmdMsg -> Comm.ReceiveMsg[AM_SIMPLECMDMSG]; RecvCmdM.IntOutput-> SendCmd; // we are doing this as we want to // forward it to other mote. }

  7. ProcessCmd command result_t ProcessCmd.execute(TOS_MsgPtr pmsg) { pending =1; msg = pmsg; post cmdInterpret(); return SUCCESS; } task void forwarder() { struct SimpleCmdMsg * cmd = (struct SimpleCmdMsg *) msg->data; call IntOutput.output(cmd->action+1 ); } task void cmdInterpret() { struct SimpleCmdMsg * cmd = (struct SimpleCmdMsg *) msg->data; // do local packet modifications: update the hop count and packet source cmd->source = TOS_LOCAL_ADDRESS; // Execute the command switch (cmd->action) { case 1: call Leds.yellowOn(); break; : : } signal ProcessCmd.done(msg, SUCCESS); }

  8. How to Assign Address to a mote? mib510=/dev/com# make mica2 install.<addr> //MakeXbowLocal DEFAULT_LOCAL_GROUP=125 //remove a comment from a line based on frequency of mote CFLAGS = -DCC1K_DEFAULT_FREQ=RADIO_433BAND_CHANNEL_00 We can send data between same groups only.

More Related