The sender is sending the pkts ( as indicated by printf messages)  but
receiver isn't  receiving. I tested the receiver with BlinkToRadio. It's
receiving. What's wrong with this code. Am i missing some header fields?
#include "Timer.h"
#include "CC2420.h"
#define MAX_LEN (TOSH_DATA_LENGTH - 4)
#include "printf.h"
module SenderC {
  uses {
    interface SplitControl as Control;
    interface SplitControl as RadioControl;
    interface Leds;
    interface Boot;
    interface Alarm<T32khz,uint32_t> as Alarm0;

    interface Send;
     interface CC2420Packet;
     interface CC2420PacketBody;
     interface AMPacket;
     interface Receive;

  }
}
implementation {
    uint32_t t1=0,t2=0,diff=0;
    am_addr_t id;
    bool busy = FALSE;
      uint16_t counter = 0;
      message_t pkt;

  event void Boot.booted() {
    call  RadioControl.start();
    call Control.start();

  }

  async event void Alarm0.fired() {
    int i;
    uint8_t * data;
    cc2420_header_t * header;
    counter++;
    printf("FIRED");
    if(busy)
    {
    call Send.cancel( & pkt ) ;
    busy=FALSE;
    }
     header = call CC2420PacketBody.getHeader( & pkt );
    header->dest= 0xffff;
    call AMPacket.setDestination(& pkt , AM_BROADCAST_ADDR);
    data =     (uint8_t *) & pkt.data[0] ;
    if (data == NULL) {
        return;
      }
      for(i=0;i<TOSH_DATA_LENGTH;i++)tinyos-help.millennium.berkeley.edu
      {
      data[i]=9;
      }

      t1= call Alarm0.getNow();

      if (call Send.send(&pkt,TOSH_DATA_LENGTH )  == SUCCESS) {
        busy = TRUE;
        printf("SENT");
        printfflush();
      }
      else
      {
           printf("Failed");
           printfflush();
           call Alarm0.startAt(0,0x10000);
      }

   }
event void Control.startDone(error_t err) {

  }
  event void Control.stopDone(error_t err) {}






    event void Send.sendDone(message_t *p_msg, error_t error){

        printf("SENDDONE %d ",counter);
        printfflush();
        t2= call Alarm0.getNow();
        diff= (t2-t1) +diff;
        if(counter<10)
        call Alarm0.startAt(0, 0x00010000);

    }

/*    async event void RadioTimeStamping.transmittedSFD(uint16_t time,
message_t *p_msg){

    }

    async event void RadioTimeStamping.receivedSFD(uint16_t time){

    }*/

    event void RadioControl.stopDone(error_t error){

    }

    event void RadioControl.startDone(error_t error){
        if (error == SUCCESS) {
      printf("STARTED");
      printfflush();
      if ( TOS_NODE_ID == 1 )
      call Alarm0.startAt(0, 10);
    }
    }



    event message_t * Receive.receive(message_t *ptr, void * abc, uint8_t
error){
        printf("Received pkt");
        return ptr;
    }
}


The configuration file is
configuration SenderAppC{
}
implementation{
  components SenderC as App, LedsC, MainC;
  components SerialActiveMessageC as AM;
  components new Alarm32khz32C() as Alarm ;


  components ActiveMessageC;
  App.AMPacket->ActiveMessageC;
  components CC2420TransmitC;
  components  CC2420PacketC;
  App.CC2420Packet -> CC2420PacketC;
  App.CC2420PacketBody -> CC2420PacketC;
  components Msp430TimerC;
  App.Boot -> MainC.Boot;
  DebugM.AMSend -> AM.AMSend[6];  // 6 is random number
  App.Leds -> LedsC;
  App.Alarm0 -> Alarm ;
  App.Debug->DebugM;
  App.Control -> AM;

  components  CC2420CsmaC;
  App.RadioControl->CC2420CsmaC;
  App.Send-> CC2420CsmaC;
  App.Receive->CC2420CsmaC;

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

Reply via email to