Reflex jamming in CCSPI now has a selectable backoff,
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 12 Feb 2012 18:07:55 +0000 (18:07 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Sun, 12 Feb 2012 18:07:55 +0000 (18:07 +0000)
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
client/goodfet.ccspi
firmware/apps/radios/ccspi.c

index 4a507d2..43001b8 100644 (file)
@@ -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;
 
index 6c2d242..28086ec 100755 (executable)
@@ -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();
 
index bad7c15..62d0130 100644 (file)
@@ -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<pkt[0];i++)
-       ccspitrans8(pkt[i]);
-      SETSS;
+    }
+    //Turn on LED 2 (green) as signal
+    PLED2DIR |= PLED2PIN;
+    PLED2OUT &= ~PLED2PIN;
+    
+    
+    
+    //Wait a few us to send it.
+    delay_us(delay);
 
-      //Transmit the packet.
-      CLRSS;
-      ccspitrans8(0x04); //STXON
-      SETSS;
-      msdelay(100+delay);      //Instead of waiting for pulse on SFD
-      //Flush TX buffer.
-      CLRSS;
-      ccspitrans8(0x09); //SFLUSHTX
-      SETSS;
+    //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<pkt[0];i++)
+      ccspitrans8(pkt[i]);
+    SETSS;
+    
+    
+    //Transmit the packet.
+    CLRSS;
+    ccspitrans8(0x04); //STXON
+    SETSS;
+    
+    //msdelay(100+delay);      //Instead of waiting for pulse on SFD
+    delay_ms(1);
+    //Flush TX buffer.
+    CLRSS;
+    ccspitrans8(0x09); //SFLUSHTX
+    SETSS;
 
-      //Turn off LED 2 (green) as signal
-      PLED2DIR |= PLED2PIN;
-      PLED2OUT |= PLED2PIN;
-    }
+    //Turn off LED 2 (green) as signal
+    PLED2DIR |= PLED2PIN;
+    PLED2OUT |= PLED2PIN;
+  }
 #else
-    debugstr("Can't reflexively jam without SFD, FIFO, FIFOP, and P2LEDx definitions - try using telosb platform.");
-    txdata(app,NOK,0);
+  debugstr("Can't reflexively jam without SFD, FIFO, FIFOP, and P2LEDx definitions - try using telosb platform.");
+  txdata(app,NOK,0);
 #endif
 }
 
@@ -248,7 +260,7 @@ void ccspi_handle_fn( uint8_t const app,
     break;
 
   case CCSPI_REFLEX:
-    ccspireflexjam(0);
+    ccspireflexjam(len?cmddataword[0]:0);
     break;
 
   case CCSPI_REFLEX_AUTOACK: