{"id":22986,"library":"winrt-windows-devices-bluetooth-advertisement","title":"winrt-windows-devices-bluetooth-advertisement","description":"Python projection of the Windows Runtime (WinRT) Bluetooth Advertisement APIs, part of the pywinrt project. Provides access to Bluetooth LE advertisement watcher, publisher, and related types. Current version 3.2.1, requires Python >=3.9, release cadence irregular (major/minor patches monthly to quarterly).","status":"active","version":"3.2.1","language":"python","source_language":"en","source_url":"https://github.com/pywinrt/pywinrt","tags":["winrt","bluetooth","windows","uwp","bluetooth-le","advertisement"],"install":[{"cmd":"pip install winrt-windows-devices-bluetooth-advertisement","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core runtime module required by all WinRT projections","package":"winrt-runtime","optional":false},{"reason":"Base types like IAsyncOperation, EventRegistrationToken","package":"winrt-windows-foundation","optional":false},{"reason":"Bluetooth device addressing and enumeration","package":"winrt-windows-devices-bluetooth","optional":false}],"imports":[{"note":"","symbol":"BluetoothLEAdvertisementWatcher","correct":"from winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisementWatcher"},{"note":"","symbol":"BluetoothLEAdvertisementPublisher","correct":"from winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisementPublisher"},{"note":"","symbol":"BluetoothLEAdvertisement","correct":"from winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisement"},{"note":"","symbol":"BluetoothLEAdvertisementDataTypes","correct":"from winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisementDataTypes"}],"quickstart":{"code":"import asyncio\nfrom winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisementWatcher\n\nasync def watch():\n    watcher = BluetoothLEAdvertisementWatcher()\n    watcher.received += lambda s, e: print(f\"Received: {e.bluetooth_address}\")\n    watcher.start()\n    await asyncio.sleep(5)\n    watcher.stop()\n\nasyncio.run(watch())","lang":"python","description":"Creates and runs a Bluetooth LE advertisement watcher for 5 seconds."},"warnings":[{"fix":"Use exact casing: `from winrt.windows.devices.bluetooth.advertisement import ...`.","message":"Breaking change in v3.0.0: namespace paths changed to match C# casing (e.g., `winrt.windows.devices.bluetooth.advertisement`). Old paths like `winrt.windows.devices.bluetooth.advertisement` (lowercase) may still exist in v2.x but are removed in v3.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use `watcher.received += handler` with a callable that accepts (sender, args).","message":"Breaking change in v3.0.0: Event registration returns `EventRegistrationToken` but no longer accepts lambdas with `+=` directly? Check documentation; `+=` pattern is supported.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use `await watcher.start()` if it returns an async action, or `watcher.start()` if it is synchronous. Check return type.","message":"Async operations must be awaited or called with `.get()` / `.wait()` (v3.2.0+). In v2.x, some async methods had to be called differently (e.g., `.start()` returns IAsyncAction). Use `await` or `asyncio.run()`.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Enable Bluetooth and grant permission in Windows Settings > Privacy & security > Bluetooth.","message":"Bluetooth LE permissions must be enabled in Windows settings. Missing permission can cause `AccessDeniedException` or silent failure.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the required base packages: `pip install winrt-runtime winrt-windows-foundation winrt-windows-devices-bluetooth`","cause":"Installed only the subpackage without the runtime or core package, or missing dependencies.","error":"ModuleNotFoundError: No module named 'winrt'"},{"fix":"Use exact import: `from winrt.windows.devices.bluetooth.advertisement import BluetoothLEAdvertisementWatcher`","cause":"Wrong import casing or version mismatch (v2.x uses different namespace).","error":"AttributeError: module 'winrt.windows.devices.bluetooth.advertisement' has no attribute 'BluetoothLEAdvertisementWatcher'"},{"fix":"Run script with administrator privileges and ensure Bluetooth is enabled in Windows settings.","cause":"Bluetooth permission not granted or administrator privileges required.","error":"winrt.system.AccessDeniedException: Access denied"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}