在python中的Bluez 5配置文件界面

时间:2015-05-21 17:44:26

标签: python dbus bluez

在Bluez5示例test-profile中,有一段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吗?这是什么意思fd.take()? int类型可以有方法吗?

问题2

在bluez 5接口文件中没有定义取消方法。哪一个是正确的?

void Release() [noreply]

void NewConnection(object device, fd, dict fd_properties)

void RequestDisconnection(object device)

0 个答案:

没有答案