[Android源码分析]蓝牙搜索过程中你所不知道的小细节

本文深入分析Android蓝牙搜索过程中远程名称请求的流程,包括Command Status Event、Remote Host Supported Features Notification Event和Remote Name Request Complete Event的处理,探讨在不同连接状态下如何获取并处理远程设备的名称。
摘要由CSDN通过智能技术生成

在上文中,我们说到蓝牙搜索并没有在收到inquiry complete的命令后就立即结束,而是会继续发送remote name request的command去得到对方的名字,本文就来和大家一起详细分析一下这些操作的流程。


10remote name request command的发送

       Remote name request从名字上我们就可以很清晰地看到,它的主要作用就是得到对端设备的名字信息。我们来从spec上看一下,这个command的格式:


命令的参数还是比较清晰的,我们在之前都已经讲过了,就不重复了。我们来看一下,他会产生哪些event。在spec中这样描述的:

When the BR/EDRController receives the Remote_Name_Request command,the BR/EDR Controllershall send the Command Status event to the Host.When the Link Managerhas completed the LMP messages to obtain the remote host supportedfeatures, if present, the BR/EDR Controller on the local BR/EDR Controllershall send a Remote Host Supported Features Notification event. When the LinkManager has completed the LMP messages to obtain the remote name, theBR/EDR Controller on the local BR/EDR Controller shall send a Remote Name RequestComplete event to the Host. If the remote host supported features page ispresent, the Remote Host Supported Features Notification

  event shall be sentbefore the Remote Name Request Complete event. If not, only the RemoteName Request Complete event shall be sent.

    大概的意思就是,首先会产生一个command status event,这个event我们在之前也看过,他除了inquirycommand会做处理外,其他的command并不会做特殊的处理。所以我们这里就不再看了哦。若是,我们没有和对方建立连接,也就是说没有ACL Connection在,那么会先去得到对端的supported features,然后产生一个Remote Host Supported Features Notificationevent。若是已经有了ACLlink,并且在之前已经得到过了remote name,则直接产生一个remote name request complete event即可。假如,我们正在建立的连接的过程中,那仍然需要先产生Remote Host Supported Features Notification

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值