I am finishing with my proyect in the university and I have a big problem.
Please, help me with my code, when I run this code in my mote telosB, the led
Blue toggle and the green led don't toggle. can anybody help me,please?
Thank.
configuration file
---------------------------------------------------------------------------------------------------------------------------------------------------------------
configuration AplicacionColaborativaAppC {
}
implementation {
components MainC, AplicacionColaborativaC as App;
components new AMSenderC(7);
components new TimerMilliC();
components BaseStationC;
components CC2420PacketC;
components LedsC;
App.Boot -> MainC.Boot;
App.AMPacket -> AMSenderC.AMPacket;
App.Intercept ->BaseStationC.RadioIntercept[15];
App.sendRssi -> AMSenderC.AMSend;
App.sendAux -> AMSenderC.AMSend;
App.TimerMain->TimerMilliC;
App.CC2420Packet -> CC2420PacketC;
App.Packet -> AMSenderC;
App.Leds -> LedsC;
}
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
implementation file
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
module AplicacionColaborativaC {
uses interface AMPacket;
uses interface Boot;
uses interface AMSend as sendRssi;
uses interface AMSend as sendAux;
uses interface Timer<TMilli> as TimerMain;
uses interface CC2420Packet;
uses interface Packet;
uses interface Leds;
uses interface Intercept;
}
implementation {
enum{
NumMotes=10,
};
uint8_t RSSI[NumMotes];
am_addr_t Origen[NumMotes];
uint8_t CopiaOrigen[NumMotes];
am_addr_t NOrigen;
am_addr_t Destino;
uint8_t des;
uint8_t PotRssi;
uint8_t temp;
am_addr_t Tabla[NumMotes];
uint8_t i;
uint8_t j;
uint8_t pos;
message_t* enviar;
event void Boot.booted(){
for(i=0;i<NumMotes;i++){
RSSI[i]=0;
Origen[i]=0;
Tabla[i]=0;
}
call TimerMain.startPeriodic(2000);
}
event void TimerMain.fired(){
if(call sendRssi.send(AM_BROADCAST_ADDR,
enviar,sizeof(enviar))==SUCCESS){
call Leds.led0On();
}
else{
call Leds.led1On();
}
}
event bool Intercept.forward(message_t *msg, void *payload, uint16_t
len) {
call Leds.led1On();
PotRssi = call CC2420Packet.getRssi(msg);
NOrigen = call AMPacket.source(msg);
pos = (uint8_t) NOrigen;
Tabla[pos] = NOrigen; // aqui tenemos los nodos que conocemos
for(i=0;i<NumMotes;i++){ //actualizar RSSI
if(Origen[i]==NOrigen){
RSSI[i]=PotRssi;
}
else{
for(i=0;i<NumMotes;i++){
if(RSSI[i]==0){
RSSI[i]=PotRssi;
Origen[i]=NOrigen;
}
}
}
}
//buscar el RSSI mayor sin perder los indices de origen
for(i=0; i<NumMotes;i++){
CopiaOrigen[i]=RSSI[i];
}
for (i=1; i<NumMotes; i++){
for (j=0 ; j<NumMotes - 1; j++){
if (CopiaOrigen[j] < CopiaOrigen[j+1]){
temp = CopiaOrigen[j];
CopiaOrigen[j] = CopiaOrigen[j+1];
CopiaOrigen[j+1] = temp;
}
}
}
//mirar si los datos son para mi, si es para mi salir, sino mirar si lo
tengo en la tabla y mandarlo directamente y sino lo envio a que mayor RSSI
tenga.
if ((call AMPacket.isForMe(msg))==TRUE){
return TRUE;
}
else{
Destino = call AMPacket.destination(msg);
des = (uint8_t)Destino;
if(Tabla[des]==Destino){//el destino del paquete está en mi tabla
call sendAux.send(Destino,msg,sizeof(msg));
}
else{//enviar Datos al q mayor rssi tenga, si los datos no son para
mi
for(i=0;i<NumMotes+1;i++){
if(CopiaOrigen[0]==RSSI[i]){
call sendAux.send(Origen[i],msg,sizeof(msg));
}
}
}
}
return TRUE;
}
event void sendRssi.sendDone(message_t* msg, error_t error){
call Leds.led0Off();
call Leds.led1Off();
}
event void sendAux.sendDone(message_t* msg, error_t error){
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_________________________________________________________________
¿Eres un cotilla? Disfruta de todas las novedades en MSN Corazón
http://entretenimiento.es.msn.com/corazon/_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help