i.MX25上的BlueZ: 无法连接RFCOMM套接字:操作正在进行中

7
我正在尝试在嵌入式Linux上连接蓝牙设备。
  • BlueZ版本为4.101。
  • 本地蓝牙适配器是一个USB蓝牙适配器Trendnet TBW-107UB,用于所有测试。
  • 很抱歉,我无法提供有关目标设备的详细信息,因为它是我工作的公司的产品。

使用this page上描述的方法在桌面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";
}

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)  

rfcomm连接输出

# rfcomm connect 0  
Can't connect RFCOMM socket: Operation now in progress  

hcitool cc 输出

# hcitool cc 00:07:80:5A:48:93  
Can't create connection: Connection timed out
# l2ping 00:07:80:5A:48:93  
Can't connect: Invalid exchange

在谷歌搜索时,我只找到了一个相关线程,暗示rfcomm connect输出可能是由于内核2.6.27回归引起的,但我的是3.10.28(使用uname-r)。 我尝试了两个其他目标蓝牙设备(不同类型),问题仍然存在。
感谢任何帮助,谢谢!
编辑 Rfkill block / unblock似乎没有改变任何东西。
2个回答

3
原来目标设备正在从我的i.MX25板请求身份验证。
通常,使用bluetooth-agent处理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

rfcomm connect 的工作原理:

# rfcomm connect 0
Connected /dev/rfcomm0 to 00:07:80:5A:48:93 on channel 1
Press CTRL-C for hangup

更新于 2015 年 06 月 15 日

今天我再次尝试了之前描述的在目标设备上运行 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目录下
  • 按照之前的方法再次尝试使用 l2ping 命令进行链接

在imx6上出现了同样的随机错误。感谢“hciconfig 0 sspmode 0”,现在连接更加稳定和快速! - ArthurLambert

0

我每天使用BT设备(智能手机)进行网络连接,使用的是blueman-applet 2.0.4

今天由于某些原因它一直失败并抛出“无法连接rfcomm套接字”错误。

我尝试了:

  • 重新启动服务[S]
  • 取消配对并重新配对,但这并没有解决问题。

直到我采取了以下步骤:

  1. Blueman-applet>设备
  2. 右键单击设备>设置>网络访问点>连接

enter image description here

之前使用“Blueman-applet > 右键单击设备 > 连接到网络访问点”失败了(今天)。我认为这不应该有任何影响,但它确实有。如果有人能够解释一下,我会非常感激。

[S]

service bluetooth stop
service network-manager stop
service networking stop
service networking restart 
service network-manager restart 
service bluetooth restart 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接