低级蓝牙实用程序

the*_*ror 18 bluetooth

什么是 Linux 的蓝牙实用程序,它可以让我配对和取消配对设备、显示来自设备的消息、向设备发送消息(希望使用文件系统完成!),并设置任何可用的标志?

考虑到的应用程序是我只想说 10 个微型蓝牙键盘并映射每个键盘上的每个键以发送 MIDI 消息(显然 MIDI 部分不是这个 OP 的一部分)。

slm*_*slm 24

下面列出了一些处理蓝牙的工具,您可以使用这些工具与设备进行交互。

配置文件

hciconfig

  • 提供有关您电脑上的蓝牙 hci 的信息
  • 确保设备已启动并正在运行并具有所需的扫描模式
  • 跑步hcitool dev也应该提供一些这样的信息

hcitool

hcitool inqhcitool scan

  • 提供有关或识别附近蓝牙设备的信息

hcitool info <BTAddr>

  • 获取有关远程蓝牙设备的信息

l2ping

l2ping <BTAddr>

  • 查看我们是否可以与远程蓝牙设备通信的一种方法

工具

sdptool browse <BTAddr> or sdptool records <BTAddr>

  • 提供有关远程蓝牙设备提供的服务的信息

文件

obexftp –nopath –noconn –uuid none –bluetooth <BTAddr> –channel <OPUSHChann elNo> –put <FileToPut>

  • 允许在不指定远程设备端的引脚的情况下发送文件
  • 设备的OPush通道号是从上面的sdptool得到的

obexftp -b <BTAddr> -v -p <FileToPut>

  • 允许将文件放到指定的 BT 设备上
  • obexftp 也可用于获取或列出 BT 设备上的文件
  • 还允许通过仅提供 -b 选项来识别附近的 BT 设备

密钥代理

passkey-agent –default <Pin>

  • 此处指定的 Pin 是远程 BT 设备应提供或用户在请求时在该设备上输入的内容。

已推送

obexpushd

  • 允许接收从蓝牙设备发送的文件。
  • 根据谁启动它,收到的文件将存储在相应的主目录中

配对

您可以按照此站点的说明通过命令行将设备与您的 Linux 机器配对。这篇文章的标题是:如何在 Linux 上从命令行配对蓝牙设备

例子

  1. 找到您的蓝牙设备mac地址

    $ hcitool scan
    
    Scanning ...
        11:22:33:44:55:66   device 1
        12:34:56:78:90:12   device 2
    
    Run Code Online (Sandbox Code Playgroud)
  2. 设置蓝牙代理以传递预期的配对代码

    $ bluetooth-agent 0000 &
    
    Run Code Online (Sandbox Code Playgroud)
  3. 编辑 rfcomm 配置文件/etc/bluetooth/rfcomm.conf,并将上面的 MAC 地址放入其中。

    rfcomm0 {
      # Automatically bind the device at startup
      bind no;
      # Bluetooth address of the device
      device 11:22:33:44:55:66;
      # RFCOMM channel for the connection
      channel 3;
      # Description of the connection
      comment "This is Device 1's serial port.";
    }
    
    Run Code Online (Sandbox Code Playgroud)

    注意:一个重要的警告,如果您将设备配置为在启动时不绑定(绑定号;),您将必须在使用串行端口(这也需要 root 权限)之前使用此命令手动启动 rfcomm。

    $ sudo rfcomm connect rfcomm0
    
    Run Code Online (Sandbox Code Playgroud)

参考