Hello,
I'm trying to build a program in order to compare the rssi values in a wireless
sensor network
and save the highest value and the id of the node that has it.I'm working with
IRIS motes and i have this program that gets compiled but gives me no feedback.
As feedback i mean the use of led toggling when sending and another led
toggling when receiving a message.Any help will be welcomed.
Thanks in advance!
#include "HelloMessages.h" #include "Timer.h"
module RssiC { uses interface Boot; uses interface AMPacket; uses interface
Leds; uses interface Receive as RssiMsgReceive; uses interface AMSend as
RssiMsgSend; uses interface SplitControl as RadioControl; // uses interface
Intercept as HelloMsgIntercept; uses interface Timer<TMilli> as RssiTimer; //
uses interface ActiveMessageC;
uses interface PacketField<uint8_t> as PacketRSSI;} implementation {uint16_t
max_rssi = 0;uint16_t max_id = 0;
HelloMsg temp1;
message_t sendbuf;
bool sendbusy;
uint16_t getRssi(message_t *msg1);
uint16_t getRssi(message_t *msg1){ if(call PacketRSSI.isSet(msg1)) return
(uint16_t) call PacketRSSI.get(msg1); else return 0xFFFF; } event void
Boot.booted(){call RadioControl.start();} event void
RadioControl.startDone(error_t err){ if (err == SUCCESS){ call
RssiTimer.startPeriodic(TIMER_PERIOD_MILLI); } else { call
RadioControl.start(); } }event void RadioControl.stopDone(error_t result){}
event void RssiTimer.fired(){ if(!sendbusy && (sizeof(temp1) <= call
RssiMsgSend.maxPayloadLength())){ memcpy(call
RssiMsgSend.getPayload(&sendbuf, sizeof(temp1)), &temp1, sizeof(temp1));
if(call RssiMsgSend.send(AM_BROADCAST_ADDR, &sendbuf, sizeof(temp1)) ==
SUCCESS){ call Leds.led2Toggle(); sendbusy = TRUE; }else{
call Leds.led0Toggle(); } }} event void
RssiMsgSend.sendDone(message_t* msg,error_t error) { sendbusy = FALSE; }
event message_t* RssiMsgReceive.receive(message_t *msg1, void *payload,
uint8_t len) {
HelloMsg *helloMsg = (HelloMsg*) payload; helloMsg -> rssi =
getRssi(msg1);
if( temp1.Arrayrssi[temp1.rssicounter] > max_rssi){ max_rssi =
temp1.Arrayrssi[temp1.rssicounter]; max_id = temp1.Arrayid[temp1.rssicounter];
call Leds.led1Toggle(); } return msg1; }}
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help