+ self.rate=rate;
+ self.chan=chan;
+ self.sync=sync;
+ self.macreject=macreject;
+ self.printing=printing;
+ self.maclen=maclen;
+
+ client.poke(0x00,0x00); #Stop nRF
+ client.poke(0x01,0x00); #Disable Shockburst
+ client.poke(0x02,0x01); #Set RX Pipe 0
+
+ #Disable shockburst.
+ client.poke(0x1C,0x00);
+ client.poke(0x1D,0x00);
+
+ client.RF_setmaclen(2); # SETUP_AW for shortest
+
+ #historic
+ #client.RF_setsmac(0x00AA);
+ #client.RF_setsmac(0x0055);
+
+ client.poke(0x00,0x70|0x03); #prime radio.
+
+ return;
+
+ def packetaddr(self,packet,justmac=False):
+ """Returns a loaded packet address, including channel and rate."""
+
+ sync=self.client.RF_getsmac()&0xFF;
+
+ mac="";
+ #MAC,RF_CH,RATE
+ for i in range(0,self.maclen):
+ mac="%s%02x" % (mac,ord(packet[i]));
+ if justmac:
+ return mac;
+ ch=self.client.peek(0x05);
+ rate=self.client.peek(0x06);
+ return "%02x,%s,%02x,%02x" % (
+ sync,mac,ch,rate);
+ def validmac(self,packet):
+ sync=self.client.RF_getsmac()&0xFF;
+ mac=self.packetaddr(packet,justmac=True);
+
+ #BT preamble is A or 5.
+ #Fix this to work on the smallest bit, not the highest.
+ if ((ord(packet[0])&0x80)^(sync&0x80)) and self.macreject:
+ #print "%02x%02x invalid entry." % (sync,ord(packet[0]));
+ #This is a special kind of failure. Freq is probably right, but MAC is wrong.
+ return False;
+ blacklist=['5555555555', 'aaaaaaaaaa',
+ '0000000000', 'ffffffffff',
+ '55555555', 'aaaaaaaa',
+ '00000000', 'ffffffff',
+ '555555', 'aaaaaa',
+ '000000', 'ffffff',
+ '7fffff', 'aaffff', 'aaaaff',
+ 'afffff', 'abffff', '5fffff'];
+ for foo in blacklist:
+ if mac==foo:
+ return False;
+ return True;
+