From 9134ed351ad68ee6c10875f02571b4c46d2072fa Mon Sep 17 00:00:00 2001 From: travisutk Date: Sun, 12 Feb 2012 18:07:55 +0000 Subject: [PATCH] Reflex jamming in CCSPI now has a selectable backoff, useful when jamming packets of a certain (longer) length. git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@1090 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- client/GoodFETCCSPI.py | 5 +- client/goodfet.ccspi | 7 ++- firmware/apps/radios/ccspi.c | 104 +++++++++++++++++++---------------- 3 files changed, 66 insertions(+), 50 deletions(-) diff --git a/client/GoodFETCCSPI.py b/client/GoodFETCCSPI.py index 4a507d2..43001b8 100644 --- a/client/GoodFETCCSPI.py +++ b/client/GoodFETCCSPI.py @@ -188,9 +188,10 @@ class GoodFETCCSPI(GoodFET): #self.strobe(0x09); return; - def RF_reflexjam(self): + def RF_reflexjam(self,duration=0): """Place the device into reflexive jamming mode.""" - data = ""; + data = [duration&0xff, + (duration>>8)&0xff]; self.writecmd(self.CCSPIAPP,0xA0,len(data),data); return; diff --git a/client/goodfet.ccspi b/client/goodfet.ccspi index 6c2d242..28086ec 100755 --- a/client/goodfet.ccspi +++ b/client/goodfet.ccspi @@ -27,7 +27,7 @@ if(len(sys.argv)==1): print "%s sniffdissect" % sys.argv[0]; print "\n%s txtoscount [-i|-r] TinyOS BlinkToLED" % sys.argv[0]; - print "%s reflexjam" % sys.argv[0]; + print "%s reflexjam [channel=11] [delay=0]" % sys.argv[0]; sys.exit(); @@ -66,11 +66,14 @@ if(sys.argv[1]=="reflexjam" or sys.argv[1]=="reflexjamack"): client.RF_setfreq(freq); else: client.RF_setchan(freq); + duration=0; + if len(sys.argv)>3: + duration=eval(sys.argv[3]); client.CC_RFST_RX(); print "Reflexively jamming on %i MHz" % (client.RF_getfreq()/10**6); #Now we let the firmware take over, watching for packets and jamming them. if sys.argv[1]=="reflexjam": - client.RF_reflexjam(); + client.RF_reflexjam(duration); elif sys.argv[1]=="reflexjamack": client.RF_reflexjam_autoack(); diff --git a/firmware/apps/radios/ccspi.c b/firmware/apps/radios/ccspi.c index bad7c15..62d0130 100644 --- a/firmware/apps/radios/ccspi.c +++ b/firmware/apps/radios/ccspi.c @@ -91,55 +91,67 @@ u8 ccspitrans8(u8 byte){ void ccspireflexjam(u16 delay){ unsigned long i; #if defined(FIFOP) && defined(SFD) && defined(FIFO) && defined(PLED2DIR) && defined(PLED2PIN) && defined(PLED2OUT) - debugstr("Reflex jamming until reset."); - txdata(CCSPI,CCSPI_REFLEX,1); //Let the client continue its business. - while(1) { - //Wait until a packet is received - while(!SFD){ - //Has there been an overflow in the RX buffer? - if((!FIFO)&&FIFOP){ - debugstr("Clearing RX overflow"); - CLRSS; - ccspitrans8(0x08); //SFLUSHRX - SETSS; - } + + prep_timer(); + debugstr("Reflex jamming until reset."); + debughex(delay); + txdata(CCSPI,CCSPI_REFLEX,1); //Let the client continue its business. + while(1) { + //Wait until a packet is received + while(!SFD){ + //Has there been an overflow in the RX buffer? + if((!FIFO)&&FIFOP){ + debugstr("Clearing RX overflow"); + CLRSS; + ccspitrans8(0x08); //SFLUSHRX + SETSS; } - //Turn on LED 2 (green) as signal - PLED2DIR |= PLED2PIN; - PLED2OUT &= ~PLED2PIN; - - //Put radio in TX mode - CLRSS; - ccspitrans8(0x04); - SETSS; - - //Load the jamming packet. - //Note: attempts to preload this actually slowed the jam time down from 7 to 9 bytes. - CLRSS; - ccspitrans8(CCSPI_TXFIFO); - char pkt[15] = {0x0f, 0x01, 0x08, 0x82, 0xff, 0xff, 0xff, 0xff, 0xde, 0xad, 0xbe, 0xef, 0xba, 0xbe, 0xc0}; - //char pkt[12] = {0x0c, 0x01, 0x08, 0x82, 0xff, 0xff, 0xff, 0xff, 0xde, 0xad, 0xbe, 0xef}; - for(i=0;i