Hi all, I want to broadcast the message which i received from another node inside the Mesh Network. Is it Possible ? cause i am using the multi-hop message.Base on my knowledge , Multihop-Message and Bcast Message have different structures.How about the received interface which one should i use ?
Below is my program and i get some error during the compiling: sensorboardApp.h:120:2: warning: no newline at end of file MyAppM.nc:207:2: warning: no newline at end of file In file included from MyApp.nc:19: In component `MyAppM': MyAppM.nc: In function `ReceiveMsg.receive': MyAppM.nc:153: `idheard' undeclared (first use in this function) MyAppM.nc:153: (Each undeclared identifier is reported only once MyAppM.nc:153: for each function it appears in.) MyAppM.nc:158: syntax error before `else' make: *** [exe0] Error 1 Program module MyAppM { provides { interface StdControl; } uses { interface Timer; interface Leds; interface StdControl as TempControl; interface ADC as Temperature; interface MhopSend as Send; interface SendMsg; interface RouteControl; interface ReceiveMsg; // the interface can only receive the non multi-hop message } } implementation { //bool sending_packet = FALSE; // MHop message bool broadcasting_packet = FALSE; // broadcasting message TOS_Msg msg_buffer1; // message sent via MHop layer //TOS_Msg msg_buffer2; // copy of the message, sent by broadcasting XDataMsg *pack1; //XDataMsg *pack2; uint8_t localHopCount; /** * Initialize the component. * * @return Always returns <code>SUCCESS</code> **/ command result_t StdControl.init() { uint16_t len; call Leds.init(); call TempControl.init(); // Initialize the message packet with default values atomic { localHopCount = 100; // the default value of localHopCount // initialize the broadcast packet pack1 = (XDataMsg*)&(msg_buffer2.data); pack1->board_id = SENSOR_BOARD_ID; pack1->packet_id = 2; pack1->node_id = TOS_LOCAL_ADDRESS; } return SUCCESS; } /** * Start things up. This just sets the rate for the clock component. * * @return Always returns <code>SUCCESS</code> **/ command result_t StdControl.start() { // Start a repeating timer that fires every 5000ms return call Timer.start(TIMER_REPEAT, 2000); } /** * Halt execution of the application. * This just disables the clock component. * * @return Always returns <code>SUCCESS</code> **/ command result_t StdControl.stop() { return call Timer.stop(); } /** * Toggle the red LED in response to the <code>Timer.fired</code> event. * Start the Temperature sensor control and sample the data * * @return Always returns <code>SUCCESS</code> **/ event result_t Timer.fired() { call Leds.redToggle(); return SUCCESS; } void task BroadcastData() { // broadcast the same message if (broadcasting_packet) return; atomic broadcasting_packet = TRUE; // broadcast the same message over radio: will be heard by other nodes if (call SendMsg.send(TOS_BCAST_ADDR,sizeof(XDataMsg),&msg_buffer2) != SUCCESS) broadcasting_packet = FALSE; return; } // runs every time the node receive a packet via radio event TOS_MsgPtr ReceiveMsg.receive(TOS_MsgPtr m) { // define local variables uint8_t idHeard, receivedHopCount; idHeard= m->data[2]; //extract sending node id from received packet receivedHopCount= m->data[3]; //extract hopCount from received packet if (idHeard == 1) // if the packet is from target atomic localHopCount = 1; else // if it is received from other nodes if ((receivedHopCount+1)<localHopCount) atomic localHopCount = receivedHopCount+1; atomic pack1->hopCount = localHopCount; post BroadcastData(); return m; } /** * Sensor data has been sucessfully sent through XMesh * Toggle green LED to signal message sent * * @return Always returns <code>SUCCESS</code> **/ event result_t SendMsg.sendDone(TOS_MsgPtr msg, result_t success) { call Leds.greenToggle(); atomic broadcasting_packet = FALSE; atomic localHopCount = 100; return SUCCESS; } }
_______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help