一个设备可以像这样被阻塞:bluetoothctl block FC:69:47:7C:9D:A3
是否有可编程的方法来列出已经被阻塞的设备?
发布于 2021-12-15 21:49:06
与BlueZ蓝牙协议栈接口的记录方法是使用D-Bus。如果语言有D总线绑定,D总线API允许大多数语言与它进行接口。
下面是一个使用Python和吡咯烷酮库的示例:
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
发布于 2021-12-15 19:08:37
是的,检查info文件:
grep Blocked /var/lib/bluetooth/*/FC:69:47:7C:9D:A3/info它将返回:
Blocked=truehttps://stackoverflow.com/questions/70367107
复制相似问题