加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – BlueZ on i.MX25:无法连接RFCOMM套接字:操作正在进行

发布时间:2020-12-14 02:14:10 所属栏目:Linux 来源:网络整理
导读:我正在尝试连接到嵌入式 Linux上的蓝牙设备. BlueZ版本是4.101. 本地蓝牙适配器是USB蓝牙适配器Trendnet TBW-107UB,适用于所有测试. 我无法提供有关目标设备的详细信息,因为它是我工作的公司的产品,抱歉. 使用描述的方法 ????this page在桌面Linux Mint 17 x
我正在尝试连接到嵌入式 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输出

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

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

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

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

解决方法

事实证明目标设备正在从我的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作品:

# 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年5月15日更新

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读