import bluetooth, time
ble = bluetooth.BLE()
ble.active(True)
found = []
def cb(ev, data):
    if ev == 5:
        addr_type, addr, adv_type, rssi, adv = data
        mac = ":".join("%02X" % b for b in bytes(addr))
        if mac not in [x[0] for x in found]:
            found.append((mac, rssi, bytes(adv).hex()[:20]))
ble.irq(cb)
ble.gap_scan(8000, 30000, 30000, True)
time.sleep(9)
ble.gap_scan(None)
for f in found:
    print(f)
print("SCAN_DONE")
