【发布时间】:2017-05-12 02:45:29
【问题描述】:
我正在使用运行 Ubuntu 和 Python 2.7 的家用计算机进行测试,希望 Raspberry Pi 3 使用具有自定义服务和特性的 BLE 进行广告宣传。我已经在两个设备以及 dbus-python 上安装了 Bluez 版本 5.42(使用推荐的方法)。我的电脑和 Raspberry Pi 都可以使用 hci0 lescan 0 命令做广告,但我想用 bluez 示例脚本做广告,example-gatt-client.py 和 example-advertisement.py 找到 here,因为我想使用我自己的自定义特征。
家用电脑 - 内核版本 4.4.0-31 通用
我可以通过在我的家用计算机上运行 example-gatt-server.py 和 example-advertise.py 来创建自定义特征和广告,而不会出现任何问题。我遇到的一个问题是我需要通过将--experimental 添加到位于/lib/systemd/system/bluetooth.service 的bluetooth.service 文件来启用Bluez 实验模式。安装 dbus-python 库也有点痛苦,因为我必须自己为 Python2 构建和安装它。
advertise.py 脚本查找名为“org.bluez.LEAdvertisingManager1”的特定广告接口。 gatt-server.py 脚本查找“org.bluez.GattManager1”。我可以通过运行以下命令来检查该接口是否存在:
dbus-send --system --dest=org.bluez --print-reply / org.freedesktop.DBus.ObjectManager.GetManagedObjects
这些接口在我的家用电脑上可以正常工作。脚本运行没有问题。
Raspberry Pi - 内核版本 4.4.38-v7+
使用相同的 bluez 版本并启用实验功能,我在尝试运行 Advertisement.py 时遇到此错误:
找不到LEAdvertisingManager1 接口。
当我执行命令“systemctl status bluetooth”时,它显示实验标志已启用,但在运行时我没有看到 LEAdvertistingManager1。
dbus-send --system --dest=org.bluez --print-reply / org.freedesktop.DBus.ObjectManager.GetManagedObjects
但是,我可以毫无问题地运行 gatt-server.py 脚本,这意味着“org.bluez.GattManager1”已找到并正常工作。我在这里错过了什么?
我已经搜索过这个问题,但唯一的建议是启用实验性功能并确保我的内核 >= 4.1。
【问题讨论】:
标签: linux python-2.7 raspberry-pi dbus bluez