首页 文章

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

提问于
浏览
5

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

  • BlueZ版本是4.101 .

  • 本地蓝牙适配器是USB蓝牙适配器Trendnet TBW-107UB,适用于所有测试 .

  • 我无法提供有关目标设备的详细信息,因为它是我工作的公司的产品,抱歉 .

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

但是,我无法将i.MX25板(嵌入式自定义Linux)连接到目标设备 . Only scan works .

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 output

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 connect output

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

hcitool cc output

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

l2ping output

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

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

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

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

1 回答

  • 2

    事实证明目标设备正在从我的i.MX25板请求验证 .
    通常,PIN码处理是通过使用bluetooth-agent完成的 .
    但是这个代理实际上没有安装在主板上(我以为是......),所以我不得不手动提供所要求的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 works :

    # 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 works :

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

    Update 06.15.2015

    今天我再次尝试在目标设备上进行l2ping,如前所述 . 出于某种原因,它会给我一个"Permission denied"错误 .
    这就是我认为的解决方法:

    • 在其他地方保存 /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

相关问题