i.MX25上的BlueZ:无法连接RFCOMM插座:正在进行操作

Vin*_*t T 6 linux bluetooth embedded-linux rfcomm bluez

我正在尝试连接到嵌入式Linux上的蓝牙设备.

  • BlueZ版本是4.101.
  • 本地蓝牙适配器是USB蓝牙适配器Trendnet TBW-107UB,适用于所有测试.
  • 我无法提供有关目标设备的详细信息,因为它是我工作的公司的产品,抱歉.

使用本页描述的方法 在Desktop Linux Mint 17 x64和RiotBoard(i.MX6)Linaro Ubuntu上运行良好.

但是,我无法将i.MX25板(嵌入式自定义Linux)连接到目标设备.只扫描有效.

rfcomm.conf

rfcomm0 {
    # Automatically bind the device at startup
    bind yes;

    # Bluetooth address of the device
    device 00:07:80:5A:48:93;

    # RFCOMM channel for the connection
    channel 1;

    # Description of the connection
    comment "Example Bluetooth device";
}
Run Code Online (Sandbox Code Playgroud)

hciconfig -a输出

hci0:   Type: BR/EDR  Bus: USB  
    BD Address: 00:15:83:44:39:E2  ACL MTU: 384:8  SCO MTU: 64:8  
    UP RUNNING PSCAN  
    RX bytes:28633 acl:0 sco:0 events:204 errors:0  
    TX bytes:899 acl:0 sco:0 commands:60 errors:0  
    Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x59 0x83  
    Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3  
    Link policy: RSWITCH HOLD SNIFF PARK  
    Link mode: SLAVE ACCEPT  
    Name: 'Bluetooth2.1+EDR CLASS1'  
    Class: 0x000000  
    Service Classes: Unspecified  
    Device Class: Miscellaneous,  
    HCI Version: 2.1 (0x4)  Revision: 0x149c  
    LMP Version: 2.1 (0x4)  Subversion: 0x149c  
    Manufacturer: Cambridge Silicon Radio (10)  
Run Code Online (Sandbox Code Playgroud)

rfcomm连接输出

# rfcomm connect 0  
Can't connect RFCOMM socket: Operation now in progress  
Run Code Online (Sandbox Code Playgroud)

hcitool cc输出

# hcitool cc 00:07:80:5A:48:93  
Can't create connection: Connection timed out
Run Code Online (Sandbox Code Playgroud)

l2ping输出

# l2ping 00:07:80:5A:48:93  
Can't connect: Invalid exchange
Run Code Online (Sandbox Code Playgroud)

在谷歌搜索时,我能找到的唯一相关线程表明rfcomm连接输出可能是由于内核2.6.27回归,但我的是3.10.28(使用uname -r).
我尝试了另外两个目标蓝牙设备(不同类型),问题依旧.

任何帮助表示赞赏,谢谢!

编辑
Rfkill阻止/解锁似乎没有任何改变.

Vin*_*t T 3

事实证明,目标设备正在向我的 i.MX25 板请求身份验证。
通常,PIN 码处理是通过使用蓝牙代理完成的。
但这个代理实际上并没有安装在主板上(我以为是......),所以我必须手动提供所请求的 PIN 码。

我就是这样做的:

  • 编辑/etc/bluetooth/rfcomm.conf,就像我之前所做的那样
  • “启动”本地 bt 适配器:hciconfig 0 up
  • 启用页面和查询扫描:hciconfig 0 piscan(我不确定这个)
  • 禁用简单配对:hciconfig 0 sspmode 0
  • 编辑(或创建)/usr/var/lib/bluetooth/ 00:15:83:44:39:E2 /pincodes
  • 在“pincodes”文件中,添加行(无引号):“ 00:07:80:5A:48:93 045678
  • 手动启动蓝牙守护进程:bluetoothd

00:15:83:44:39:E2是本地设备蓝牙地址。
00:07:80:5A:48:93是目标设备蓝牙地址。
045678是目标设备 PIN 码。

l2ping 工作原理:

# l2ping 00:07:80:5A:48:93
Ping: 00:07:80:5A:48:93 from 00:15:83:44:39:E2 (data size 44) ...
4 bytes from 00:07:80:5A:48:93 id 0 time 13.14ms
4 bytes from 00:07:80:5A:48:93 id 1 time 26.34ms
Run Code Online (Sandbox Code Playgroud)

rfcomm 连接工作原理:

# rfcomm connect 0
Connected /dev/rfcomm0 to 00:07:80:5A:48:93 on channel 1
Press CTRL-C for hangup
Run Code Online (Sandbox Code Playgroud)

更新 06.15.2015

今天,我再次在该目标设备上尝试 l2ping,如前所述。由于某种原因,它会抛出“权限被拒绝”错误。
这就是我想出的解决方法:

  • /usr/var/lib/bluetooth/ 00:15:83:44:39:E2 /pincodes保存到其他地方
  • 删除/usr/var/lib/bluetooth/ 00:15:83:44:39:E2下的所有内容
  • 重启
  • 将保存的pincodes文件放回到/usr/var/lib/bluetooth/ 00:15:83:44:39:E2下
  • 如前所述重试 ping