python中的bluez5 profile接口

2024-03-29 02:03:15 发布

您现在位置:Python中文网/ 问答频道 /正文

在Bluez5示例testprofile中,有一个python代码块:

class Profile(dbus.service.Object):
    fd = -1

    @dbus.service.method("org.bluez.Profile1",
                    in_signature="", out_signature="")
    def Cancel(self):
        print("Cancel")


    @dbus.service.method("org.bluez.Profile1",
                in_signature="oha{sv}", out_signature="")
    def NewConnection(self, path, fd, properties):
        self.fd = fd.take()
        print("NewConnection(%s, %d)" % (path, self.fd))
        for key in properties.keys():
            if key == "Version" or key == "Features":
                print("  %s = 0x%04x" % (key, properties[key]))
            else:
                print("  %s = %s" % (key, properties[key]))

我是Python和Bluez的新手,下面是一些问题:

问题1

什么是fd?它是文件描述符的int?这是什么意思?int类型可以有方法吗?在

问题2

bluez 5接口文件中未定义Cancel方法。哪一个是正确的?在

^{pr2}$

Tags: keyinorgselfservicepropertiesoutcancel