def status(self):
"""Read the status byte."""
- self.poke(0x07,0x78); #Reset status
status=self.peek(0x07);
print "Status=%02x" % status;
#Register 0A is RX_ADDR_P0, five bytes.
mac=self.peek(0x0A, 5);
return mac;
+ def RF_setsmac(self,mac):
+ """Set the source MAC address."""
+
+ #Register 0A is RX_ADDR_P0, five bytes.
+ self.poke(0x0A, mac, 5);
+ return mac;
+ def RF_gettmac(self):
+ """Return the target MAC address."""
+
+ #Register 0x10 is TX_ADDR, five bytes.
+ mac=self.peek(0x0A, 5);
+ return mac;
+ def RF_settmac(self,mac):
+ """Set the target MAC address."""
+
+ #Register 0x10 is TX_ADDR, five bytes.
+ self.poke(0x10, mac, 5);
+ return mac;
+ def RF_rxpacket(self):
+ """Get a packet from the radio. Returns None if none is waiting."""
+ if self.peek(0x07) & 0x40:
+ #Packet has arrived.
+ self.writecmd(self.NRFAPP,0x80,0,None); #RX Packet
+ data=self.data;
+ self.poke(0x07,0x40);#clear bit.
+ return data;
+ elif self.peek(0x07)==0:
+ self.writecmd(self.NRFAPP,0x82,0,None); #Flush
+ self.poke(0x07,0x40);#clear bit.
+ return None;
import sys;
import binascii;
import array;
+import time;
from GoodFETNRF import GoodFETNRF;
from intelhex import IntelHex;
for r in range(0,30):
print "r[0x%02x]=0x%02x" % (r,client.peek(r));
-
+if(sys.argv[1]=="sniffob"):
+ #Reversal of transmitter code from nRF_CMD.c
+ client.poke(0x00,0x00); #Stop nRF
+ client.poke(0x01,0x00); #Disable Shockburst
+ client.poke(0x02,0x01); #Set RX Pipe 0
+ client.poke(0x03,0x03); #SETUP_AW for 5-byte addresses.
+ client.RF_freq(2481 * 10**6);
+ client.poke(0x06,0x09); #2MBps, -18dBm in RF_SETUP
+ client.poke(0x07,0x78); #Reset status register
+
+ #OpenBeacon defines these in little endian as follows.
+ #0x01, 0x02, 0x03, 0x02, 0x01
+ client.RF_setsmac(0x0102030201);
+ #'O', 'C', 'A', 'E', 'B'
+ client.RF_settmac(0x424541434F);
+
+ #Set packet length of 16.
+ client.poke(0x11,16);
+
+ client.status();
+ #Power radio, prime for RX, checksum.
+ client.poke(0x00,0x70|0x03|0x08);
+
+
+ print "Listening as %010x on channel %03i" % (client.RF_getsmac(),client.peek(0x05));
+ #Now we're ready to get packets.
+
+ while 1:
+ packet=None;
+ while packet==None:
+ time.sleep(0.1);
+ client.status();
+ packet=client.RF_rxpacket();
+ s="";
+ for foo in packet:
+ s="%s %02x" % (s,ord(foo));
+ print "Got %s" %s;