import bluetooth import sys target_name = "Logitech MX900 Mouse" target_address = '00:07:61:09:59:46' #nearby_devices = bluetooth.discover_devices() #for bdaddr in nearby_devices: # if target_name == bluetooth.lookup_name( bdaddr ): # target_address = bdaddr # break if target_address is not None: rx = bluetooth.BluetoothSocket(bluetooth.L2CAP) try: rx.connect((target_address,0x13)) except bluetooth.BluetoothError: print 'Unable to associate' sys.exit() while True: print '---' dd = rx.recv(1024) print len(dd) else: print 'no device found'