在上文中,我们说到蓝牙搜索并没有在收到inquiry complete的命令后就立即结束,而是会继续发送remote name request的command去得到对方的名字,本文就来和大家一起详细分析一下这些操作的流程。
10、remote 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我们在之前也看过,他除了inquiry的command会做处理外,其他的command并不会做特殊的处理。所以我们这里就不再看了哦。若是,我们没有和对方建立连接,也就是说没有ACL Connection在,那么会先去得到对端的supported features,然后产生一个Remote Host Supported Features Notification的event。若是已经有了ACLlink,并且在之前已经得到过了remote name,则直接产生一个remote name request complete event即可。假如,我们正在建立的连接的过程中,那仍然需要先产生Remote Host Supported Features Notification的