bluezutils.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:bluetool 作者: emlid 项目源码 文件源码
def find_device_in_objects(objects, device_address, adapter_pattern=None):
    bus = dbus.SystemBus()
    path_prefix = ""

    if adapter_pattern:
        adapter = find_adapter_in_objects(objects, adapter_pattern)
        path_prefix = adapter.object_path

    for path, ifaces in objects.items():
        device = ifaces.get(DEVICE_INTERFACE)

        if device is None:
            continue

        if (device["Address"] == device_address and path.startswith(
                path_prefix)):
            obj = bus.get_object(SERVICE_NAME, path)
            return dbus.Interface(obj, DEVICE_INTERFACE)

    raise BluezUtilError("Bluetooth device not found")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号