繁体   English   中英

bluetoothctl 有没有办法查看被阻止的设备?

[英]Is there a way in bluetoothctl to view devices that are blocked?

可以像这样阻止设备: bluetoothctl block FC:69:47:7C:9D:A3

有没有办法列出已经被阻止的设备?

是的,检查info文件:

grep Blocked /var/lib/bluetooth/*/FC:69:47:7C:9D:A3/info

它将返回:

Blocked=true

与 BlueZ 蓝牙堆栈接口的记录方法是使用 D-Bus API。 如果语言具有 D-Bus 绑定,则 D-Bus API 允许大多数语言与其交互。

这是使用 Python 和pydbus库的示例:

import pydbus

dev_iface = 'org.bluez.Device1'
bus = pydbus.SystemBus()
mngr = bus.get('org.bluez', '/')

mngd_objs = mngr.GetManagedObjects()

for path, info in mngd_objs.items():
    blocked = info.get(dev_iface, {}).get('Blocked')
    if blocked is not None:
        address = info.get(dev_iface, {}).get('Address')
        print(f'[{address}] is {"Blocked" if blocked else "Not Blocked"}')

BlueZ 设备 API 记录在:

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/device-api.txt

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM