Jisha,

The following code is just an example which  sends a message to "destid"
periodically and blinks corresponding LEDs depending on the reception of
ack. Analyzing it may give you some idea.

But there will not be any ACK for broadcast messages (as per my limited
knowledge).

-------------------------
    event void Boot.booted()
    {
        call timer.startPeriodic(1000);
        call radiocontrol.start();
    }
    event void timer.fired()
    {
        nx_uint16_t * pntr =  (nx_uint16_t *) call
AMSend.getPayload(&wtmsg,sizeof(testdata));
        (*pntr) = testdata;
        if(call PacketAcknowledgements.requestAck(&wtmsg)==SUCCESS)
            call Leds.led0Toggle();
        call AMSend.send(destid, &wtmsg, sizeof(testdata));
    }
    event void radiocontrol.stopDone(error_t error){}
    event void radiocontrol.startDone(error_t error){}
    event void AMSend.sendDone(message_t *msg, error_t error)
    {
        if ( msg == &wtmsg && call PacketAcknowledgements.wasAcked(msg) )
                  call Leds.led1Toggle();
        else
                 call Leds.led2Toggle();
    }
---------------------------------------------------------------

Thanks
Jobish John


On Thu, Jul 31, 2014 at 11:32 AM, Jisha Mary Jose <jishamary1...@gmail.com>
wrote:

> Hi,
>
> Can you tell me the steps to check for acknowledgements for packets send
> in tinyos?
>
> I did this:
> event void AMSend.sendDone(message_t *msg, error_t error)
>   {
>     dbg("All", "%s Send Done\n", sim_time_string());
>     if(call PacketAcknowledgements.wasAcked(msg))
>       dbg("All", "%s Acknowledged\n", sim_time_string());
>     else
>         dbg("All", "%s not acked\n", sim_time_string());
>   }
>
>
>  task void send()
>   {
>      call PacketAcknowledgements.requestAck(&msg);
>
>   }
>
>  event void TrickleTimer.fired[uint8_t id]() {
> if (call AMSend.send(AM_BROADCAST_ADDR, &m_buf,
> sizeof(dissemination_message_t)) == SUCCESS) {
>
>     post send();
> }
>
> But i am getting an error as msg is undefined in the "task void send()
> line". Bo i tried passing msg as a parameter to send(), but that is not
> possible. How to solve this error?
>
> Please help me,
>
> Regards,
>
> Jisha Mary Jose
> ......jMj......
>
> _______________________________________________
> Tinyos-help mailing list
> Tinyos-help@millennium.berkeley.edu
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to