#self.strobe(0x09);
return;
+ def RF_reflexjam(self):
+ """Place the device into reflexive jamming mode."""
+ data = ""
+ self.writecmd(self.CCSPIAPP,0xA0,len(data),data);
+ return;
def RF_modulated_spectrum(self):
"""Hold a carrier wave on the present frequency."""
print "%s bsniff [chan]" % sys.argv[0];
print "%s sniffdissect" % sys.argv[0];
-
- print;
- print "%s txtoscount [-i|-r] TinyOS BlinkToLED" % sys.argv[0];
-
+ print "\n%s txtoscount [-i|-r] TinyOS BlinkToLED" % sys.argv[0];
+ print "%s reflexjam" % sys.argv[0];
+
sys.exit();
#Initialize FET and set baud rate
while(1):
time.sleep(1);
+if(sys.argv[1]=="reflexjam"):
+ client.RF_promiscuity(1);
+ client.RF_autocrc(0);
+ if len(sys.argv)>2:
+ freq=eval(sys.argv[2]);
+ if freq>100:
+ client.RF_setfreq(freq);
+ else:
+ client.RF_setchan(freq);
+ client.CC_RFST_RX();
+ print "Listening as %010x on %i MHz" % (client.RF_getsmac(),
+ client.RF_getfreq()/10**6);
+ client.RF_reflexjam();
+
if(sys.argv[1]=="info"):
print "Found %s" % client.identstr();
print "Freq: %05f MHz" % (client.RF_getfreq()/(10**6));
break;
case CCSPI_RX:
#ifdef FIFOP
- //Has there been an overflow?
+ //Has there been an overflow?
if((!FIFO)&&FIFOP){
debugstr("Clearing overflow");
CLRSS;
//ccspitrans8(0x3F|0x40);
cmddata[0]=0xff; //to be replaced with length
for(i=0;i<cmddata[0]+2;i++)
- cmddata[i]=ccspitrans8(0xde);
+ cmddata[i]=ccspitrans8(0xde);
SETSS;
//Flush buffer.
txdata(app,verb,0);
break;
+
case CCSPI_REFLEX:
- debugstr("Coming soon.");
- txdata(app,verb,0);
+ debugstr("Beta implementation.");
+ cmddata[0] = 1;
+ txdata(app,verb,cmddata[0]+1);
+
+ while(1) {
+ //Wait until a packet is received
+ while(!SFD);
+ //Turn on LED 2 (green) as signal
+ PLED2DIR |= PLED2PIN;
+ PLED2OUT &= ~PLED2PIN;
+
+ //Switch the radio to TX mode
+ CLRSS; //Drop !SS to begin transaction.
+ ccspitrans8(0x04);
+ SETSS; //Raise !SS to end transaction.
+ //txdata(app,verb,len);
+
+ //Load the packet.
+ CLRSS;
+ ccspitrans8(CCSPI_TXFIFO);
+ char pkt[15] = {0x0f, 0x01, 0x08, 0x82, 0xff, 0xff, 0xff, 0xff, 0xde, 0xad, 0xbe, 0xef, 0xba, 0xbe, 0xc0};
+ for(i=0;i<pkt[0];i++)
+ ccspitrans8(pkt[i]);
+ SETSS;
+ debugstr("Packet loaded for tx.");
+ //Transmit the packet.
+ CLRSS;
+ ccspitrans8(0x04); //STXON
+ SETSS;
+ //Wait for the pulse on SFD, after which the packet has been sent.
+ //while(!SFD);
+ //while(SFD);
+ msdelay(300);
+ //Flush TX buffer.
+ CLRSS;
+ ccspitrans8(0x09); //SFLUSHTX
+ SETSS;
+
+ //while(SFD);
+ //msdelay(200);
+ //Turn off LED 2 (green) as signal
+ PLED2DIR |= PLED2PIN;
+ PLED2OUT |= PLED2PIN;
+ }
+ //TODO the firmware stops staying in this mode after a while, and stops jamming... need to find a fix!
break;
+
case CCSPI_TX_FLUSH:
- //Flush the buffer.
+ //Flush the buffer.
CLRSS;
ccspitrans8(CCSPI_SFLUSHTX);
SETSS;
#include <io.h>
#endif
-//LED on P5.4
+//LED on P5.4 (LED1 red)
#define PLEDOUT P5OUT
#define PLEDDIR P5DIR
#define PLEDPIN BIT4
+//LED on P5.5 (LED2 green)
+#define PLED2OUT P5OUT
+#define PLED2DIR P5DIR
+#define PLED2PIN BIT5
+//LED on P5.6 (LED3 blue)
+#define PLED3OUT P5OUT
+#define PLED3DIR P5DIR
+#define PLED3PIN BIT6
#define SPIOUT P3OUT
#define CLRSS P4OUT&=~BIT2
#define DIRSS P4DIR|=BIT2
-
//Flash CS is P4.4, redefine only for the SPI app.
#ifdef SPIAPPLICATION
#undef SETSS
#define FIFOP (P1IN&BIT0)
#define FIFO (P1IN&BIT3)
+//GPIO Expansion Pins
+#define GIO0 (P2OUT&BIT0)
+#define GIO0HIGH P2OUT|=BIT0
+#define GIO0LOW P2OUT&=~BIT0
+#define GIO0OUT P2OUT
+#define GIO0DIR P2DIR
+#define GIO0PIN BIT0
+
// network byte order converters
#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \
(((uint16_t)(x) & 0x00FF) << 8))