【问题标题】:How to turn off Bluetooth pairing on Linux/Ubuntu?如何在 Linux/Ubuntu 上关闭蓝牙配对?
【发布时间】:2020-07-16 19:09:02
【问题描述】:

我已经根据https://people.csail.mit.edu/albert/bluez-intro/x502.html 的示例编写了一个蓝牙客户端应用程序和一个蓝牙服务器应用程序。

服务器应用在 Raspberry Pi 上运行,客户端在 Ubuntu 18.04 机器上运行。

通信按预期进行。

我注意到,客户端第一次连接时,会弹出一个系统窗口(在客户端 Ubuntu 框上)询问配对请求。

我的客户端代码最终会在没有显示器的设备上运行。我无法为客户端/服务器通信进行任何用户交互。

第一季度。客户端正在进行套接字调用:

s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

有没有可以用来禁止配对的标志?在我的客户端中,客户端和服务器都不真正关心安全连接。

第二季度。当我在两台设备上运行工具“bluetoothctl”时,我看到客户端框中列出了配对设备,但在服务器设备上根本看不到任何配对设备。这怎么可能?我认为配对始终是一种双向信任关系。以及如何通信仍然有效?

第三季度。简单的蓝牙客户端/服务器通信是否需要配对?

【问题讨论】:

    标签: bluetooth


    【解决方案1】:

    当在客户端的bluetoothctl 中时,有几件事值得检查。

    除了查看设备配对状态外,还要检查服务器设备是否受信任以及是否列出了串行端口配置文件。

    [bluetooth]# info B8:27:EB:22:57:E0 
    Device B8:27:EB:22:57:E0 (public)
            Name: SeeMe
            Alias: SeeMe
            Class: 0x00480000
            Paired: yes
            Trusted: no
            Blocked: no
            Connected: no
            LegacyPairing: no
            UUID: Serial Port               (00001101-0000-1000-8000-00805f9b34fb)
    
    

    您可以使用trust <dev_addr>trust <dev_addr> 信任 bluetoothctl 中的设备

    如果您在配对时服务器正在运行,则串行端口配置文件将出现在列表中。

    您还可以告诉 BlueZ,您的客户端设备没有可用于配对的输入或输出设备。在 bluetoothctl 中。

    [bluetooth]# agent off
    Agent unregistered
    [bluetooth]# agent NoInputNoOutput
    Agent registered
    [bluetooth]# 
    

    我希望这已经足够了,但除此之外,大多数配置文件都是在服务器上使用 Profile API 注册的,在服务器上可以指定 RequireAuthentication 和 RequireAuthorization 选项。不确定如何在您的设置中进行设置。 https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/profile-api.txt#n85

    【讨论】:

      猜你喜欢
      • 2013-01-27
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2021-07-03
      • 2022-08-22
      相关资源
      最近更新 更多