# ble_scan_v0b.py

from ubluetooth import BLE

def bt_irq_handler(event, data):
  if event == 5: # Advertiser-Datenpaket erhalten
    addr_type, addr, adv_type, rssi, adv_data = data
    print('Address-Type: ', addr_type)
    print('Address: ', [hex(n) for n in addr])
    print('ADV-Type: ', adv_type)
    print('RSSI in dBm: ', rssi)
    print('ADV-Data: ', [hex(n) for n in adv_data])
    print()
  elif event == 6: # Scan beendet
    print('-----------------------------------------------------------')
    print('scan complete')

bt = BLE()
bt.active(True)
bt.irq(bt_irq_handler)
bt.gap_scan(5000, 100000, 25000)

