2020-04-09 11:39:45 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2021-09-01 00:00:36 +02:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#
|
2024-02-07 17:26:12 +01:00
|
|
|
# Copyright (c) 2016-2024, Olivier Martin <olivier@labapart.org>
|
2021-09-01 00:00:36 +02:00
|
|
|
#
|
|
|
|
|
2020-04-09 11:39:45 +02:00
|
|
|
import argparse
|
|
|
|
|
|
|
|
from gattlib import adapter
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(description='Gattlib BLE Advertising Data example')
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
def on_discovered_ble_device(device, user_data):
|
2024-04-24 10:22:15 +02:00
|
|
|
advertisement_data, manufacturer_data = device.get_advertisement_data()
|
2020-04-09 11:39:45 +02:00
|
|
|
print("Device Advertisement Data: %s" % manufacturer_data)
|
|
|
|
|
|
|
|
|
|
|
|
# Use default adapter
|
|
|
|
default_adapter = adapter.Adapter()
|
|
|
|
|
2020-04-09 11:49:19 +02:00
|
|
|
# Scan indefinitely
|
2020-04-09 11:39:45 +02:00
|
|
|
default_adapter.open()
|
|
|
|
default_adapter.scan_enable(on_discovered_ble_device, 0, notify_change=True)
|