我正在尝试运行以下python脚本:https://github.com/Jumperr-labs/python-gatt-server(gatt server example.py),这是一个蓝牙低能服务器
它在我的计算机上运行得非常好,但是当我尝试在intel edison上运行它时,我得到以下错误:
Failed to register advertisement: org.bluez.Error.NotPermitted: Maximum
advertisements reached
Python dbus和Bluez安装在此设备上(Bluez v5.50)。我正在寻找一种方法来清理注册广告,如果有一些,并得到启动我的服务器上这个英特尔爱迪生
{a1}为错误提供了一点解释:
因此,错误来自
RegisterAdvertisement
调用:清理以前注册的广告的一种“强力”方法是,在运行BLE服务器之前,始终重新启动蓝牙服务
一种更“优雅”的方法是尝试确保您的BLE服务器实现具有适当的关闭或清理处理。当服务器进程结束/退出时,尝试调用BlueZ广告管理器和GATT管理器API
Unregister*
方法:UnregisterAdvertisement
UnregisterApplication
您可能还需要^{} 创建的
GLib.MainLoop
在accepted answer中提到的example-gatt-server不执行此操作,但是您也可以检查example-advertisement代码(也来自BlueZ),该代码执行操作:
注意
mainloop
退出时,main
函数以cleanup调用结束https://github.com/Jumperr-labs/python-gatt-server中的代码只是BlueZ代码的移植/重新组织版本。一个改进是修改
advertising
和gatt-server
模块以添加适当的清理一种方法是使用SIGTERM信号优雅地终止BLE服务器进程,然后catching that SIGTERM within the app
如果从github.com/edison-fw运行最新的Yocto映像,并切换到最新的python3example gatt server,则服务器运行时不会出错。Bluetoothctl
show
显示在关闭gatt服务器后,心率服务会自动取消注册相关问题 更多 >
编程相关推荐