首页 > 编程知识 正文

经典蓝牙协议栈,传统蓝牙协议栈结构

时间:2023-05-04 15:18:41 阅读:179080 作者:1087

零. 概述主要介绍蓝牙堆栈串行协议(bluetooth SPP )串行端口配置文件协议的概念。

一. 声明本专栏的文章将通过连载不断更新。 本专栏的更新内容如下。

第一个:蓝牙的综合介绍,主要是介绍蓝牙的概念,产生背景、发展轨迹、上市蓝牙介绍、蓝牙开发板介绍。

第2篇:传输层介绍主要介绍蓝牙协议栈和蓝牙芯片以前的硬件传输协议,如基于UART的H4、H5、BCSP、基于USB的H2等

第三篇:传统蓝牙控制器介绍主要介绍传统蓝牙芯片,包括射频(RF )、基带层(baseband )、链路管理层(LMP )等

第四篇:传统蓝牙主机介绍主要介绍HCI、L2CAP、SDP、RFCOMM、HFP、SPP、HID、AVDTP、AVCTP、A2DP、AVRCP、OBEX、PBAP、MMP

第五篇:低功耗蓝牙控制器介绍,主要介绍低功耗蓝牙芯片、物理层(PHY )、链路层(ll )

第六篇:包括低功耗蓝牙主机介绍、低功耗蓝牙协议栈介绍、HCI、L2CAP、ATT、GATT、SM等

第七篇:蓝牙芯片介绍,主要介绍几种蓝牙芯片的初始化流程,基于HCI vendor command的扩展

第八篇:附录主要介绍上述常用名词的介绍和一些特殊流程的介绍等。

另外,开发板对于想学习蓝牙协议栈的人来说,一套就可以了,如下所示。 为了更好地学习蓝牙协议栈,请相信我。 学习了这个视频集之后,你有能力修改任何协议栈。 例如,Linux下的bluez,Android下的bluedroid )。

请参见----------------------------------------- -

3358 www.Sina.com/https://edu.csdn.net/lecturer/5352? spm=1002.2001.3001.4144

CSDN学院链接(进入选择你想要学习的课程):970324688

33558 www.Sina.com/https://github.com/SJ 15712795029/bluetooth _ stack

3358 www.Sina.com/https://item.Taobao.com/item.htm? SPM=a1z 10.1-c-s.w 4004-22329603896.18.5 aeb 41 f 973 ist rid=622836061708

3358 www.Sina.com/: https://blog.csdn.net/xiaoxiao pengbo/article/details/107727900

请参见----------------------------------------- -

蓝牙交流扣扣群:2.1概念介绍SPP是串行端口配置文件(串行协议)的缩写,RS232 )等使用蓝牙的设备用于串行电缆模拟的协议简单地说,在蓝牙设备之间建立虚拟串行端口以进行数据通信。 简而言之,这两个设备可以端到端地发送定制数据。 NOTED :苹果不支持SPP协议。

目前SIG的最新版本是V1.2,之前的版本官网只能下载V1.1,这两个文档没有功能上的区别,所以不介绍

2.2整个蓝牙的spp协议架构图示如下

2.3角色介绍devicea(Deva )thisisthedevicethattakesinitiativetoformaconnectiontoanotherdevice

deviceb(devb )thisisthedevicethatwaitsforanotherdevicetotakeinitiativetoconnect。

简而言之,连接了两台设备,谁开始的连接的作用是Device A,连接的是Device B。 但是,这与其他协议不同,两台设备前面的代码基本相同,作用只是区分两台设备。

2.4 SPP特性

p>

Device A是发起连接的主动房,所以Device A要至少支持Establish link and set up virtual serial connection.,Device B是被连接的乙方,所以要至少支持Accept link and establish virtual serial connection和Register Service record for application in local SDP database.以便Device A查询服务并且连接,但是此协议漏掉最主要的两个功能,发送数据,接收数据,或者SIG是觉得rfcomm做到了这个功能,所以不写在SPP协议中吧,但是我还是决定要在SPP介绍收发功能。

2.4.1 Establish link and set up virtual serial connection.

This procedure refers to performing the steps necessary to establish a connection to an emulated serial port (or equivalent) in a remote device. The steps in this procedure are:

1)Submit a query using SDP to find out the RFCOMM Server channel number of the desired application in the remote device. This might include a browsing capability to let the user select among available ports (or services) in the peer device. Alternatively, if it is known exactly which service to contact, it is sufficient look up the necessary parameters using the Service Class ID associated with the desired service.

2)Optionally, require authentication of the remote device to be performed. Also optionally, require encryption to be turned on.

3)  Request a new L2CAP channel to the remote RFCOMM entity.

4)  Initiate an RFCOMM session on the L2CAP channel.

5)  Start a new data link connection on the RFCOMM session, using the aforementioned server channel number.After step 5, the virtual serial cable connection is ready to be used for communication between applications on both sides.

2.4.2 Accept link and establish virtual serial connection.

This procedure refers to taking part in the following steps:

1)If requested by the remote device, take part in authentication  procedure and, upon

further request, turn on encryption.

2)  Accept a new channel establishment indication from L2CAP.

3)  Accept an RFCOMM session establishment on that channel.

4)  Accept a new data link connection on the RFCOMM session. This may trigger a local request to authenticate the remote device and turn on  encryption, if the user has required that for the emulated serial port being connected to (and authentication/encryption procedures have not already been carried out).

2.4.3 Register Service record for application in local SDP database.

This procedure refers to registration of a service record for an emulated serial port (or equivalent) in the SDP database. This implies the existence of a Service Database, and the ability to respond to SDP queries.

NOTED:SPP只有安卓手机支持,并且部分安卓手机必须有SPP APP才可以连接,iphone手机不能直接SPP,但是又一个替代协议IAP,此协议需要买MFI chip才能用

2.5 SDP相关的注册

我看下我们的SDP注册:

static const uint8_t spp_service_record[] ={/* 1.ServiceClassIDList */ SDP_DES_SIZE8, 0x8, SDP_UINT16, BT_ATTRIBUTE_SERVICE_CLASS_ID_LIST>>8&0xff, BT_ATTRIBUTE_SERVICE_CLASS_ID_LIST&0xff, /* Service class ID list attribute */ SDP_DES_SIZE8, 3, SDP_UUID16, BT_SERVICE_CLASS_SERIAL_PORT>>8&0xff, BT_SERVICE_CLASS_SERIAL_PORT&0xff,/* 2.ProtocolDescriptorList */ SDP_DES_SIZE8, 0x11, SDP_UINT16, BT_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST>>8&0xff, BT_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST&0xff,/* Protocol descriptor list attribute */ SDP_DES_SIZE8, 0xc, SDP_DES_SIZE8, 0x3, SDP_UUID16, BT_PROTOCOL_L2CAP>>8&0xff, BT_PROTOCOL_L2CAP&0xff, /*L2CAP*/ SDP_DES_SIZE8, 0x5, SDP_UUID16, BT_PROTOCOL_RFCOMM>>8&0xff, BT_PROTOCOL_RFCOMM&0xff, /*RFCOMM*/ SDP_UINT8, RFCOMM_SPP_SERVER_CHNL, /*RFCOMM channel*//* BluetoothProfileDescriptorList */ SDP_DES_SIZE8, 0xd, SDP_UINT16, BT_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST>>8&0xff, BT_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST&0xff, /* profile descriptor List */ SDP_DES_SIZE8, 0x8, SDP_DES_SIZE8,0x06, SDP_UUID16,BT_SERVICE_CLASS_SERIAL_PORT>>8&0xff, BT_SERVICE_CLASS_SERIAL_PORT&0xff, SDP_UINT16,0x01,0x02,/* V1.2 */};

 

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。