【问题标题】:BlueZ on i.MX25 : Can't connect RFCOMM socket: Operation now in progressi.MX25 上的 BlueZ:无法连接 RFCOMM 套接字:操作正在进行中
【发布时间】:2015-07-31 00:28:07
【问题描述】:

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

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

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

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 输出

# l2ping 00:07:80:5A:48:93  
Can't connect: Invalid exchange

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

感谢您的帮助,谢谢!

编辑
Rfkill block / unblock 似乎没有改变任何东西。

【问题讨论】:

    标签: linux bluetooth embedded-linux bluez rfcomm


    【解决方案1】:

    我每天都使用 BT 设备(智能手机)使用 blueman-applet 2.0.4 进行联网

    今天由于某种原因,它一直在抛出失败。

    “无法连接 rfcomm 套接字”。

    我试过了

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

    直到我做了以下事情:

    1. Blueman 小程序 > 设备
    2. 右键单击设备 > 设置 > 网络接入点 > 连接

    使用“Blueman-applet > 右键单击​​设备 > 连接到网络接入点”之前(今天)失败了。我认为这不应该有所作为,但确实如此。如果有人能提供一些启示,我将不胜感激。

    [S]

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

    【讨论】:

      【解决方案2】:

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

      这就是我的做法:

      • 编辑 /etc/bluetooth/rfcomm.conf,就像我之前所做的那样
      • “Up”本地 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 连接有效:

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

      更新 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

      【讨论】:

      • imx6 上的相同随机错误。感谢“hciconfig 0 sspmode 0”,现在连接更加稳定和快速!
      猜你喜欢
      • 2014-04-27
      • 2018-07-08
      • 2019-02-08
      • 1970-01-01
      • 2018-02-21
      • 2013-06-28
      • 2021-02-27
      • 2013-02-21
      • 2021-11-04
      相关资源
      最近更新 更多