X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFETCCSPI.py;h=0e2d787b1a216477cebb9fe8036f4940724fb43e;hp=78273ac5774cabcd8b9e0db2b2e6b42731880c4b;hb=a5b5dc2e02ec49f9fc9164e0e5cd70b18e48f635;hpb=443bcd972725a80fd8d55014d4f1d84485ec53f0 diff --git a/client/GoodFETCCSPI.py b/client/GoodFETCCSPI.py index 78273ac..0e2d787 100644 --- a/client/GoodFETCCSPI.py +++ b/client/GoodFETCCSPI.py @@ -5,7 +5,7 @@ # # This code is being rewritten and refactored. You've been warned! -import sys, time, string, cStringIO, struct, glob, serial, os; +import sys, time, string, cStringIO, struct, glob, os; from GoodFET import GoodFET; @@ -89,7 +89,8 @@ class GoodFETCCSPI(GoodFET): reg, val, self.peek(reg,bytes)); - return; + return False; + return True; def status(self): """Read the status byte.""" @@ -135,13 +136,15 @@ class GoodFETCCSPI(GoodFET): fsctrl=0x8000; #self.peek(0x18)&(~0x3FF); fsctrl=fsctrl+int(mhz-2048) self.poke(0x18,fsctrl); - self.strobe(0x02); + self.strobe(0x02);#SCAL + self.strobe(0x03);#SRXON def RF_getfreq(self): """Get the frequency in Hz.""" fsctrl=self.peek(0x18); mhz=2048+(fsctrl&0x3ff) return mhz*1000000; def RF_setchan(self,channel): + """Set the ZigBee/802.15.4 channel number.""" if channel < 11 or channel > 26: print "Only 802.15.4 channels 11 to 26 are currently supported."; else: @@ -186,24 +189,20 @@ 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; - def RF_reflexjam_seq(self): + def RF_reflexjam_autoack(self): """Place the device into reflexive jamming mode - and return the sequence number of the jammed packet.""" - #TODO make so that this function someone keeps receiving - # the sequence numbers from each jammed frame, or probably - # just make the firmware auto-ack if the frame requests - # an ACK instead of sending data back to client. - data = "\0"; - self.data = data; + and that also sends a forged ACK if needed.""" + data = ""; self.writecmd(self.CCSPIAPP,0xA1,len(data),data); - buffer = self.data; - return ord(buffer[3]); + print "Got:", data, "and", self.data + return; def RF_modulated_spectrum(self): """Hold a carrier wave on the present frequency.""" @@ -282,6 +281,14 @@ class GoodFETCCSPI(GoodFET): mdmctrl0=mdmctrl0|0x0020; self.poke(0x11,mdmctrl0); return; + def RF_autoack(self,autoack=1): + mdmctrl0=self.peek(0x11); + if autoack==0: + mdmctrl0=mdmctrl0&(~0x0010); + else: + mdmctrl0=mdmctrl0|0x0010; + self.poke(0x11,mdmctrl0); + return; packetlen=16; def RF_setpacketlen(self,len=16): """Set the number of bytes in the expected payload."""