Bluez配置文件注册

2024-10-01 09:25:49 发布

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

我正在尝试让一个蓝牙设备在Bluez5上用Python工作。目前我有以下情况:

    #set up a bluez profile to advertise device capabilities from a loaded service record
def init_bluez_profile(self):

    print("Configuring Bluez Profile")

    #setup profile options
    service_record=self.read_sdp_service_record()

    opts = {
        "ServiceRecord":service_record,
        "Role":"server",
        "RequireAuthentication":False,
        "RequireAuthorization":False,
        "Name":BTKbDevice.MY_DEV_NAME,
        "AutoConnect":True
    }

    #retrieve a proxy for the bluez profile interface
    bus = dbus.SystemBus()
    self.manager = dbus.Interface(bus.get_object("org.bluez","/org/bluez"), "org.bluez.ProfileManager1")
    self.profile = BTKbBluezProfile(bus, BTKbDevice.PROFILE_DBUS_PATH)
    self.manager.RegisterProfile(BTKbDevice.PROFILE_DBUS_PATH, BTKbDevice.UUID, opts)
    print("Profile registered ")

此代码正确执行,配置文件代码是bluez测试用例中的标准代码:

^{pr2}$

然而,当我得到连接/断开连接时,什么都不起作用。我尝试过各种各样的选择,但就是没法注册。文档很简单,而且似乎没有什么关于dbus通信的调试信息。有没有人成功地注册了一个配置文件和/或获得了关于bluez交互的更多调试信息?在

谢谢。在


Tags: 代码orgselffalseservicemanagerrecordprofile