python-ble-scanner.py

MikroTik KNOT Gateway HL9 · File : python-ble-scanner.py · Language : Python · Use case : Scanner les périphériques Bluetooth LE environnants pour le suivi d'actifs via le module BT 5.1.

Python script using the Bleak library to detect nearby BLE devices.

Requires Python 3 and the 'bleak' library. The HL9 exposes its Bluetooth interface via the internal bus. Run with sudo if radio access permissions are needed. Useful for identifying asset tags.

python-ble-scanner.py

import asyncio
from bleak import BleakScanner

async def main():
    print("Scanning for BLE devices...")
    devices = await BleakScanner.discover(timeout=10.0)
    for d in devices:
        print(f"{d.address}: {d.name}")

if __name__ == "__main__":
    asyncio.run(main())

← Back to the board