Hey,

The code looks fine.

I'd suggest you go step wise by first making one of the motes just a sender
and the other just a receiver.

See if that works.

cheers,
Nishad

On Thu, May 9, 2013 at 2:34 AM, Sandeep Bezawada <[email protected]>wrote:

>
> 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
>



-- 
Sincerely,

Nishad Kamdar
Graduate student
BITS PILANI , K K Birla Goa campu*s*
Cell: +919503218809
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to