X-Git-Url: http://git.rot13.org/?p=goodfet;a=blobdiff_plain;f=client%2FGoodFET.py;h=d5e132f6c59956e1644132153725fc00396f5e52;hp=ab6bb09cd2cc4a4113c0be832538997cdb37bef6;hb=3b792eaee038953bb9d73f29a80aaebcf6399655;hpb=f3dbea2333da46a5f73aa4036048f10e718c015c diff --git a/client/GoodFET.py b/client/GoodFET.py index ab6bb09..d5e132f 100755 --- a/client/GoodFET.py +++ b/client/GoodFET.py @@ -52,18 +52,23 @@ class GoodFETbtser: """py-bluez class for emulating py-serial.""" def __init__(self,btaddr): import bluetooth; - while btaddr==None or btaddr=="none" or btaddr=="bluetooth": + if btaddr==None or btaddr=="none" or btaddr=="bluetooth": print "performing inquiry..." nearby_devices = bluetooth.discover_devices(lookup_names = True) print "found %d devices" % len(nearby_devices) for addr, name in nearby_devices: print " %s - '%s'" % (addr, name) + #TODO switch to wildcards. if name=='FireFly-A6BD': btaddr=addr; + if name=='RN42-A94A': + btaddr=addr; + + print "Please set $GOODFET to the address of your device."; + sys.exit(); print "Identified GoodFET at %s" % btaddr; - # BlueFET doesn't run the Service Discovery Protocol. - # Instead we manually use the portnumber. + # Manually use the portnumber. port=1; print "Connecting to %s on port %i." % (btaddr, port); @@ -72,18 +77,27 @@ class GoodFETbtser: sock.connect((btaddr,port)); sock.settimeout(10); #IMPORTANT Must be patient. - #Once connected, we need to get synced. - #This might require a firmware patch. - str=None; - while str!="http://goodfet.sf.net/": - str=self.read(64); - print str; + ##This is what we'd do for a normal reset. + #str=""; + #while not str.endswith("goodfet.sf.net/"): + # str=self.read(64); + # print str; + + # Instead, just return and hope for the best. + return; + def write(self,msg): """Send traffic.""" - return self.sock.send(msg); - def read(self,len): + import time; + self.sock.send(msg); + #time.sleep(0.1); + return; + def read(self,length): """Read traffic.""" - return self.sock.recv(len); + data=""; + while len(data)