Hi all,

I am new to sensor networks. I am working on a project that does load
balancing. But in my project Receive event is not working. So, I tried to
do simple send and receive but no luck.

Please see my code below

implementation {
  bool busy = FALSE;

  message_t pkt;
  uint16_t counter = 1;
  bool fwd =  FALSE;


/*--------------------------------------------------------------*/
  event void Boot.booted() {

      call AMControl.start();
  }
  /*--------------------*/
event void AMControl.startDone(error_t err) {
    if (err == SUCCESS) {
      call Timer0.startPeriodic(300);
    }
    else {
      call AMControl.start();
    }
  }

  event void AMControl.stopDone(error_t err) {
  }

  /*-----*/
event void Timer0.fired() {

  if (!busy) {
    BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)(call
Packet.getPayload(&pkt, sizeof (BlinkToRadioMsg)));
    btrpkt->nodeid = TOS_NODE_ID;
    btrpkt->counter = counter;
    if (call AMSend.send(AM_BROADCAST_ADDR, &pkt, sizeof(BlinkToRadioMsg))
== SUCCESS) {
     * printf("AM layer sends\n");*
      busy = TRUE;
    }
  }
}
  /*------------*/
event void AMSend.sendDone(message_t* msg, error_t error) {
    if (&pkt == msg) {
     * printf("sent successfully\n");*
      busy = FALSE;
    }
  }
  /*-------------*/
event message_t* Receive.receive(message_t* msg, void* payload, uint8_t
len) {
  if (len == sizeof(BlinkToRadioMsg)) {
    BlinkToRadioMsg* btrpkt = (BlinkToRadioMsg*)payload;
   * printf("receive\n");*
    call Leds.set(btrpkt->counter);
  }
  return msg;
}
}

I have installed this on 3 mica2 motes and tested

My output is
AM layer sends
sent succesfully
..
..


But receive is not printing
Please help

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

Reply via email to