【问题标题】:Pybluez on Nano: SDP can’t be generatedNano 上的 Pybluez:无法生成 SDP
【发布时间】:2022-02-05 06:59:41
【问题描述】:

我的 Nano 遇到了这样的问题:

profiles = [ SERIAL_PORT_PROFILE ],
  File \"/usr/lib/python2.7/site-packages/bluetooth/bluez.py\", line 176, in advertise_service
    raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, \'No such file or directory\')

我尝试在 bluetooth.service 文件中添加兼容模式,重新加载守护进程,重新启动蓝牙,然后通过执行添加串行端口

sudo sdptool add SP

这些步骤在我的 ubuntu 20.04 笔记本电脑上运行良好,但在 jetpack 4.5.1 上却不行。我也查了一下,它们也不适用于 jetson NX。

我真的很好奇如何解决这个问题,否则,欢迎在 python 代码中使用蓝牙的另一种方法。

谢谢

    标签: python bluetooth nvidia-jetson-nano pybluez


    【解决方案1】:

    您可能想看看下面的文章,它展示了如何与核心 Python Socket 库进行连接 https://blog.kevindoran.co/bluetooth-programming-with-python-3/

    BlueZ 现在执行此操作的方式是使用 Profile API。

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/test-profile 有一个使用 Profile API 的 Python 示例

    hciattachhciconfighcitoolhcidumprfcommsdptoolciptoolgatttool 是 2017 年的 deprecated by the BlueZ 项目。如果您正在学习使用它们的教程,它有可能已经过时并且 Linux 系统会选择不支持它们。

    【讨论】:

    • 嗨 ukBaz,感谢您的回答。但是,您能否分享一个如何使用它与外部设备通信的示例?
    • 我假设bluetoothctl 在命令行上工作?如果是这样,Python3 示例中的哪些内容不适合您?你得到什么错误?你的代码是什么样的?您想用更多信息更新问题吗?
    • 好的,找到了解决方案,看我的回答
    【解决方案2】:

    解决方案在蓝牙配置文件的路径中(灵感来自https://developer.nvidia.com/embedded/learn/tutorials/connecting-bluetooth-audio

    这个答案:bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

    对于jetson设备(jetpack)来说是不够的。尽管我没有测试它是否可以在不更改此链接中提到的文件的情况下工作。

    还有一个.conf 文件也需要更改:/lib/systemd/system/bluetooth.service.d/nv-bluetooth-service.conf

    调整 :

    ExecStart=/usr/lib/bluetooth/bluetoothd -d --noplugin=audio,a2dp,avrcp
    

    至 :

    ExecStart=/usr/lib/bluetooth/bluetoothd -C
    

    之后有必要做:

    sudo systemctl daemon-reload
    sudo systemctl restart bluetooth
    

    使用 jetpach 4.5.1 在 jetson Nano 和 NX 上进行测试

    谢谢您的帮助 !

    【讨论】:

      猜你喜欢
      • 2012-10-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-12
      • 1970-01-01
      • 2021-04-21
      • 2013-03-13
      • 2020-08-24
      • 2018-03-22
      相关资源
      最近更新 更多