Hello,

I'm new to TinyOs, so please excuse me for the long email. I've been
developing an application using CTP on a group of micaz motes. The idea
is for them to monitor some sensors, and send them to the collection
base. The data arrives but I've also been asked to track the route a
packet follows.

I have read the archives such as:
 
http://www.mail-archive.com/[email protected]/msg20973
.html

where the advice is "you will need to put the
local node id in the packet somewhere each time it is forwarded."

That I understand, and so far I've added some fields to my data
structure. One of them is hopcount, and several Node0x fields to add
possible hops. The idea is to increment hopcount each forward and write
in the appropriate Node0x field the TOS_NODE_ID.

Wiring:

components CollectionC as Collector;
App.Forward -> Collector.Intercept[COL_ID];

And in the module:

uses interface Intercept as Forward;

event bool Forward.forward(message_t* msg, void* payload, uint8_t len)
  {
    if (!busy){
      
      RadMsg* aux1 = (RadMsg*)payload;
      
      RadMsg *aux2 = (RadMsg*)call Send.getPayload(&pkt_int,
sizeof(RadMsg));
      
      busy = TRUE;
      
      if (aux1->nodeid == TOS_NODE_ID) //To avoid forwarding when it is
the                                                        //own node
      {
        return FALSE;
      }else{
        
        call Leds.led0Toggle();
        aux2->Voltage = aux1->Voltage;
        aux2->TempValue = aux1->TempValue;
        aux2->PhotoValue = aux1->PhotoValue;
        aux2->nodeid = aux1->nodeid;
        aux2->HopCount = aux1->HopCount;
        aux2->NodoInterm01 = aux1->NodoInterm01;
        aux2->NodoInterm02 = aux1->NodoInterm02;
        aux2->NodoInterm03 = aux1->NodoInterm03;
        aux2->NodoInterm04 = aux1->NodoInterm04;
        aux2->NodoInterm05 = aux1->NodoInterm05;
                
        aux2->HopCount++; 
        
          switch (aux2->HopCount)
        {
          case 1: aux2->Node01 = TOS_NODE_ID;
                  break;
          case 2: aux2->Node02 = TOS_NODE_ID;
                  break;
          case 3: aux2->Node03 = TOS_NODE_ID;
                  break;
          case 4: aux2->Node04 = TOS_NODE_ID;
                  break;
          case 5: aux2->Node05 = TOS_NODE_ID;
                  break;
          default: break;
        }    
        
        check(call Send.send(&pkt_int, sizeof(RadMsg)));//Here I resend
the                                             //new message with the
new hop added.
        
        return TRUE;
      }      
    }else{
      return FALSE;
    }
    
  }  

Now this "seems" to work, as I'm receiving the data with the hops I more
or less expected, but I'm not sure if I'm doing it the correct way. I
also have a doubt about what happens if more messages arrive to be
forwarded while I'm sending one, or the nodes own readings. Should I
make a queue?

Please tell me if I'm using intercept the way it's meant to.

Thanks in advance.
Manuel.



Este mensaje se dirige exclusivamente a su destinatario, y puede contener 
información confidencial sometida a secreto profesional, o cuya divulgación 
esté legalmente prohibida. Cualquier opinión en él contenida es exclusiva de su 
autor y no representa necesariamente la opinión de la empresa. Si ha recibido 
este mensaje por error, le rogamos nos lo comunique de forma inmediata por esta 
misma vía y proceda a su eliminación, así como a la de cualquier documento 
adjunto al mismo. El correo electrónico vía Internet no es seguro y no se puede 
garantizar que no haya errores ya que puede ser interceptado, modificado, 
perdido o destruido, o contener virus. Cualquier persona que se ponga en 
contacto con nosotros por correo electrónico se considerará que asume estos 
riesgos.

This e-mail is addressed exclusively to the recipient and may contain 
privileged information under a professional confidential agreement or it may be 
against the law to disclose its contents. Any opinion contained in it belongs 
exclusively to his/her author and does not necessarily reflect the company’s 
view. If you receive this e-mail in error, please let us know immediately (by 
return e-mail) and proceed to its destruction, as well as any document attached 
to it. The sending of e-mails through the Internet is not safe and, therefore, 
error-free communications cannot be guaranteed, as they can be intercepted, 
changed, misled or destroyed or they might contain a virus. Any user contacting 
us through e-mails shall be understood to be assuming these risks.



_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to