def discover_devices(duration=8, flush_cache=True, lookup_names=False, lookup_class=False, device_id=-1): #this is order of items in C-code btAddresIndex = 0 namesIndex = 1 classIndex = 2 try: devices = bt.discover_devices(duration=duration, flush_cache=flush_cache) except OSError: return [] ret = list() for device in devices: item = [ device[btAddresIndex], ] if lookup_names: item.append(device[namesIndex]) if lookup_class: item.append(device[classIndex]) if len(item ) == 1: # in case of address-only we return string not tuple ret.append(item[0]) else: ret.append(tuple(i for i in item)) return ret
def discover_devices (duration=8, flush_cache=True, lookup_names=False, lookup_class=False): #this is order of items in C-code btAddresIndex = 0 namesIndex = 1 classIndex = 2 devices = bt.discover_devices() ret = list() for device in devices: item = [device[btAddresIndex],] if lookup_names: item.append(device[namesIndex]) if lookup_class: item.append(device[classIndex]) if len(item) == 1: # in case of address-only we return string not tuple ret.append(item[0]) else: ret.append(tuple(i for i in item)) return ret