Hi All,

I'm trying to use the AMSnooperC interface to snoop for messages
forwarded by a neighboring node, including requests and
acknowledgements (ACK) transmissions. The problem is: although snoop
messages from a neighbor, a node cannot capture messages ACK sent by
their neighbours. What am I doing wrong?
Ex: node 1-> send-> node4.
node3-> snoop-> node 1

Topology:
1 4 -80.0
4 1 -80.0
1 3 -80.0
3 1 -80.0

Parts of the code:

BlinkToRadioAppC

#include <Timer.h>
#include "BlinkToRadio.h"
configuration BlinkToRadioAppC {
}
.
.
.
components new AMSnooperC(AM_BLINKTORADIO);
  App.Snoop -> AMSnooperC;
}
--------------------------------------------------------------------------------------------------------------------------
module BlinkToRadioC {

.
.
.

event void Timer0.fired() {
    counter++;
    if (!busy) {
      BlinkToRadioMsg* btrpkt =
       (BlinkToRadioMsg*)(call Packet.getPayload(&pkt, NULL));
      btrpkt->nodeid = TOS_NODE_ID;
      btrpkt->counter = counter;

        if (TOS_NODE_ID == 1){
      dbg("BlinkC", "%s\t Timer 0 fired send nodeID: %d\n",
sim_time_string(), btrpkt->nodeid);
      //dbg("BlinkC", "%s\t Timer 0 fired send count: %d\n",
sim_time_string(), btrpkt->counter);
      call PacketAcknowledgements.requestAck(&pkt);
      if (call AMSend.send(4,
          &pkt, sizeof(BlinkToRadioMsg)) == SUCCESS) {
        busy = TRUE;
      }
     }
    }
  }

  event void AMSend.sendDone(message_t* msg, error_t err) {

        if (&pkt == msg) {
      busy = FALSE;
    }
        contSend++;
        dbg("BlinkC", "%s\t AMSend.sendDone CounterSender: %d\n",
sim_time_string(), contSend);
        if( call PacketAcknowledgements.wasAcked(msg) )
                                ++ackedCount;
                        else
                                ++ackedError;
        dbg("BlinkC", "%s\t AMSend.sendDone: ackcount %d\n",
sim_time_string(), ackedCount);
        dbg("BlinkC", "%s\t AMSend.sendDone: ackError %d\n",
sim_time_string(), ackedError);
  }

   event message_t* Snoop.receive(message_t* msg, void* payload, uint8_t len)
   {

        BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
        dbg("BlinkC", "%s\t Snoop.receive nodeID: %d\n",
sim_time_string(), btrpkt->nodeid);
        if( call PacketAcknowledgements.wasAcked(msg) )
                                ++ackedCount;
                        else
                                ++ackedError;

        dbg("BlinkC", "%s\t Snoop.receive: ackcount %d\n", sim_time_string(),
ackedCount);
        dbg("BlinkC", "%s\t Snoop.receive: ackError %d\n", sim_time_string(),
ackedError);
        dbg("BlinkC", "%s\t Snoop.receive: CounterSender: %d\n",
sim_time_string(), contSend);

    return msg;
   }

  event message_t* Receive.receive(message_t* msg, void* payload, uint8_t len){
      BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
      dbg("BlinkC", "%s\t Receive.receive nodeID: %d\n",
sim_time_string(), btrpkt->nodeid);
      setLeds(btrpkt->counter);
        contReceive++;
        dbg("BlinkC", "%s\t Receive.receive CounterReceive: %d\n",
sim_time_string(), contReceive);

        

    return msg;
  }
}

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

Reply via email to