X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETCCSPI.py;h=518add32343696291392d8cbe4dc9abc82831660;hp=3b787d549ed537532df652f28ba68c123de09886;hb=d08bfd3c7cdc687fd68ba9025702c262665e52d3;hpb=db9bb1922d4093829cb9d7eb9d37a2dbce96b0ae diff --git a/client/GoodFETCCSPI.py b/client/GoodFETCCSPI.py index 3b787d5..518add3 100644 --- a/client/GoodFETCCSPI.py +++ b/client/GoodFETCCSPI.py @@ -115,7 +115,7 @@ class GoodFETCCSPI(GoodFET): #Radio stuff begins here. def RF_setenc(self,code="802.15.4"): """Set the encoding type.""" - return; + return code; def RF_getenc(self): """Get the encoding type.""" return "802.15.4"; @@ -136,6 +136,12 @@ class GoodFETCCSPI(GoodFET): print "ERROR: Forgot to set the key."; return; + def RF_setnonce(self,key): + """Sets the first key for encryption to the given argument.""" + print "ERROR: Forgot to set the nonce."; + + return; + def RF_setfreq(self,frequency): """Set the frequency in Hz.""" mhz=frequency/1000000; @@ -174,6 +180,21 @@ class GoodFETCCSPI(GoodFET): """Returns the received signal strength, with a weird offset.""" rssival=self.peek(0x13)&0xFF; #raw RSSI register return rssival^0x80; + + def peekram(self,adr,count): + """Peeks data from CC2420 RAM.""" + data=[ + adr&0xFF,adr>>8, # Address first. + count&0xFF,count>>8 # Then length. + ]; + self.writecmd(self.CCSPIAPP,0x84,len(data),data); + return self.data; + def pokeram(self,adr,data): + """Pokes data into CC2420 RAM.""" + data=[adr&0xFF, adr>>8]+data; + self.writecmd(self.CCSPIAPP,0x85,len(data),data); + return; + lastpacket=range(0,0xff); def RF_rxpacket(self): """Get a packet from the radio. Returns None if none is @@ -189,6 +210,13 @@ class GoodFETCCSPI(GoodFET): return None; return buffer; + def RF_rxpacketrepeat(self): + """Gets packets from the radio, ignoring all future requests so as + not to waste time. Call RF_rxpacket() after this.""" + + self.writecmd(self.CCSPIAPP,0x91,0,None); + return None; + def RF_rxpacketdec(self): """Get and decrypt a packet from the radio. Returns None if none is waiting.""" @@ -336,11 +364,13 @@ class GoodFETCCSPI(GoodFET): self.poke(0x03,choice); self.maclen=len; def printpacket(self,packet,prefix="#"): + print self.packet2str(packet,prefix); + def packet2str(self,packet,prefix="#"): s=""; i=0; for foo in packet: s="%s %02x" % (s,ord(foo)); - print "%s%s" % (prefix,s); + return "%s%s" % (prefix,s); def printdissect(self,packet): try: