Commits

Anonymous committed e2b37d8

Clean open/close interfaces
not using pppd setdefaultroute since it's not avail in all pppd's

Comments (0)

Files changed (5)

-pylint -e src/bbtether/*py
 cd src
 tar czvf ../bbtether.tgz bbtether
 cd ..
+pylint -e src/bbtether/*py

src/bbtether/bb_data.py

 	def claim_interface(self):
 		self.handle.claimInterface(self.interface)
 		
+	def release_interface(self):
+		self.handle.releaseInterface()
+
 	def read_infos(self):
 		''' read pin and description and store them in this data structure'''
 		self.pin=bb_usb.get_pin(self)

src/bbtether/bb_usb.py

 	print "	Max Power:", config.maxPower
 	for inter in config.interfaces:
 		print "	Interface:",inter[0].interfaceNumber
+		handle.claimInterface(inter[0].interfaceNumber)
 		print "		Interface class:",inter[0].interfaceClass,"/",inter[0].interfaceSubClass
 		print "		Interface protocol:",inter[0].interfaceProtocol
 		for att in inter:
 					if readpt != -1 and modem_readpt == -1:
 						# use pair after data pair as Modem pair
 						modem_readpt=red
-						modem_writept=writ	
-	
-		device.readpt=readpt
-		device.writept=writept
-		device.modem_readpt=modem_readpt
-		device.modem_writept=modem_writept
+						modem_writept=writ
+		handle.releaseInterface()
+
+	device.readpt=readpt
+	device.writept=writept
+	device.modem_readpt=modem_readpt
+	device.modem_writept=modem_writept
 
 def clear_halt(device, endpt):
 	device.handle.clearHalt(endpt)

src/bbtether/bbtether.py

 				print "\nUsing Data Endpoint Pair:",hex(berry.readpt),"/",hex(berry.writept);				
 				print "Using first pair after Data pair as Modem pair: ",hex(berry.modem_readpt),"/",hex(berry.modem_writept),"\n"
 				
+				print "Claiming interface"
 				berry.claim_interface()
 				
 				berry.read_infos()
 					
 				# This will run forever (until ^C)
 				modem.start(pppConfig,pppdCommand)				
-			
+
+				print "Releasing interface"
+				berry.release_interface()
 		else:
 			print "\nNo RIM device found"
 	

src/bbtether/conf/tmobile

 novj
 user guest
 password guest
-replacedefaultroute
+# does not exist in all pppd versions (osx)
+#replacedefaultroute
 
 connect "/usr/sbin/chat -v -V -f conf/tmobile-chat"