def find_device_by_name(name): s = Scanner() scan_res = s.scan(1000) device_names = get_device_names(scan_res) for dev in device_names: if name == dev[1]: return dev[0]
def find_device_by_name(name): s = Scanner() scan_res = s.scan(500) device_names = get_device_names(scan_res) for dev in device_names: if name == dev[1]: return dev[0]
def find_device_by_name(name): s = Scanner() scan_res = s.scan(100) device_names = get_device_names(scan_res) for dev in device_names: if name == dev[1]: return dev[0] # >>> res = find_device_by_name("micr") # >>> if res: # ... print("address:", res.addr()) # ... print("address type:", res.addr_type()) # ... print("rssi:", res.rssi()) # ... # ... # ... # address: c2:73:61:89:24:45 # address type: 1 # rssi: -26
from ubluepy import Scanner, constants def display_scan_results(scan_entries): for e in scan_entries: print("ADDR: ", e.addr()) print("TYPE: ", e.addr_type()) print("RSSI: ", e.rssi()) # Parse the contents of the advertising packet scan = e.getScanData() if scan: for s in scan: # Convert byte array to hex format string hex = ' '.join('0x%02X' % b for b in s[2]) # Display enum value and hex string together print('\t{}: {}'.format(s[1], hex)) # Line break between record sets print("") # Scan 1s for advertising devices in range s = Scanner() scan_res = s.scan(1000) # Display the scan results display_scan_results(scan_res)