Platform tested
MicaZ and TelosB ( Should work with Imote also)
Interfaces neededBoot : To boot up the device
Leds : To indicate data capture
Receive : To capture the packet (provided by CC2420ReceiveC)
SplitControl : To control the radio
CC2420PacketBody : For reading the packet header
To run the program, assuming that you are using telosb , type in the shell/command prompt
java net.tinyos.tools.PrintfClient -comm serial@/dev/ttyUSB0:telosb
SniffC.nc
----------------
#include "printf.h"
module SniffC
{
uses
{
interface Boot;
interface Leds;
interface Receive as Rx;
interface SplitControl as RadioControl;
interface CC2420PacketBody as CPacketBody;
}
}
implementation
{
event void Boot.booted()
{
call RadioControl.start();
}
event void RadioControl.startDone(error_t err)
{
}
event void RadioControl.stopDone(error_t err)
{
}
event message_t* Rx.receive(message_t*msg,void*payload,uint8_t len)
{
uint8_t i;
cc2420_header_t *h=call CPacketBody.getHeader(msg);
for(i=0;i
printf("%u",msg->data[i]);
printf("\n");
printfflush();
call Leds.led1Toggle();
return msg;
}
}
SniffAppC.nc
------------------
configuration SniffAppC
{
}
implementation
{
components CC2420ReceiveC as CCC, LedsC, MainC, SniffC, CC2420CsmaC as CCS,CC2420PacketC as CCP;
SniffC.Boot->MainC;
SniffC.Leds->LedsC;
SniffC.Rx->CCC;
SniffC.CPacketBody->CCP;
SniffC.RadioControl-> CCS;
}
Makefile
COMPONENT=SniffAppC
CFLAGS+= -I$(TOSDIR)/lib/printf
CFLAGS += -DCC2420_NO_ACKNOWLEDGEMENTS
CFLAGS += -DCC2420_NO_ADDRESS_RECOGNITION
CFLAGS += -DENABLE_SPI0_DMA
include $(MAKERULES)