博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
蓝牙 hci
阅读量:5950 次
发布时间:2019-06-19

本文共 12954 字,大约阅读时间需要 43 分钟。

1 /*  2   3  There are two basic types of physical links that can be established  4  between a master and a slave:  5   6  Synchronous Connection Oriented ( SCO )  7  Asynchronous Connection-Less ( ACL )  8   9  An SCO link provides a symmetric link between the master and the slave, 10  *********** 11  with regular periodic exchange of data in the form of reserved slots. 12  Thus, the SCO link provides a circuit-switched connection 13  where data are regularly exchanged, 14  and as such it is intended for use with time-bounded information as audio. 15  16  A master can support up to three SCO links to the same or to different slaves. 17  A slave can support up to three SCO links from the same master. 18  19  Audio - Audio data is carried via SCO (Synchronous Connection Oriented) channels 20  21  An ACI link is a point-to-multipoint link between the master 22  *********** 23  and all the slaves on the piconet. It can use all of the remaining slots 24  on the channel not used for SCO links. 25  The ACL link provides a packet-switched connection 26  where data are exchanged sporadically, 27  as they become available from higher layers of the stack. 28  29  The traffic over the ACL link is completely scheduled by the master. 30  31  Each Bluetooth device has a 48 bit IEEE MAC address that 32  is used for the derivation of the access code. 33  34  The form of a MAC address - Copyright Spill & Bittau 35  NAP[15:0] : UAP[7:0] : LAP[23:0] 36  The NAP is only two bytes long and the First byte is generally zero 37  38  All packets have the same format, starting with an access code, 39  followed by a packet header and ending with the user payload 40  41  Access Code       Header      Payload 42  68 or 72 bits     54 bits     0 - 2745 bits 43  44  The access code is used to address the packet to a specific device. 45  The header contains all the control information associated with the packet and the link. 46  The payload contains the actual message information. 47  48  49  An HCI packet consisting of an HCI header and HCI data 50  shall be contained in one USB Transfer. 51  52  A USB transfer is defined by the USB specification as 53  one or more USB transactions that contain the data from one IO request 54  55  For example, 56  an ACL data packet containing 256 bytes (both HCI header and HCI data) 57  would be sent over the bulk endpoint in one IO request 58  59  That IO request will require four 64-byte full speed USB Transactions or 60  a single 256-byte Highspeed USB Transaction, and forms a Transfer 61  62  If the Maximum Packet Size for the endpoint on which the transfer is sent 63  is 64 bytes, then that IO request will require four 64-byte USB transactions. 64  65  USB Primary firmware interface and endpoint settings 66  67  Interface   Alternate   Endpoint    Endpoint        PacketSize 68  Number      Setting     Address     Type 69  HCI Commands  N/A         N/A         0x00        Control         8/64 70  HCI Events    0           0           0x81        Interrupt
16 71 ACL/AMP Data 0 0 0x82 Bulk
64 72 ACL/AMP Data 0 0 0x02 Bulk
64 73 74 *************** CONTROL ENDPOINT EXPECTATIONS ********************************** 75 76 Endpoint 0 is used to configure and control the USB device. 77 Endpoint 0 will also be used to allow the host to 78 send HCI-specific commands to the host controller. 79 80 All HCI Control Packets delivered to Endpoint 0 are addressed 81 in the Setup Data structure 82 83 The bmRequestType can be used to select the Device or the Interface. 84 If Interface is selected, the wIndex parameter 85 must select the Index for the targeted Bluetooth controller 86 87 For a single function Primary Controller, 88 the Host should address HCI command packets to the Device. 89 HCI command packets should be sent with the following parameters: 90 91 *** HCI command packet addressing for single-function Primary controllers : 92 93 bmRequestType 0x20 : Host-to-device class request, device as target 94 bRequest 0x00 95 wValue 0x00 96 wIndex 0x00 97 98 Note: For historical reasons, if the Primary Controller firmware receives a 99 packet over this endpoint, it should treat the packet as an HCI command100 packet regardless of the value of bRequest, wValue and wIndex.101 Some Host devices set bRequest to 0xE0.102 103 *** Primary Controller Function in a Composite Device104 105 bmRequestType 0x21 : Host-to-interface class request, interface as target106 bRequest 0x00107 wValue 0x00108 wIndex IF# : This is the actual Interface # within the composite device.109 110 If the Host system driver addresses USB requests containing HCI command packets111 to the Device instead of to the Interface, the device implementation shall112 recognize these HCI command packets and correctly route them to113 the Primary Controller function, to ensure correct operation of114 the Primary Controller function and avoid malfunctions in other functions115 contained in the composite device.116 117 *** HCI command packet addressing for single-function AMP Controller118 119 bmRequestType 0x21 : Host-to-interface class request, interface as target120 bRequest 0x2B : Arbitrary value chosen to identify requests targeted to an AMP controller function.121 wValue 0x00122 wIndex IF# : This is the actual Interface # within the composite device.123 124 125 *************** BULK ENDPOINT EXPECTATIONS *************************************126 127 Data integrity is a critical aspect for ACL data. This,128 in combination with bandwidth requirements,129 is the reason for using a bulk endpoint. Multiple 64-byte packets can be shipped130 per USB Frame (1 millisecond, full speed) or 512-byte packets per USB Microframe131 (125 microseconds, high-speed), across the bus.132 133 Suggested bulk max packet size is 64 bytes for full-speed,134 or 512 bytes for high speed.135 136 Bulk has the ability to detect errors and correct them.137 In order to avoid starvation, a flow control model similar138 to the shared endpoint model is recommended for the host controller.139 140 ***************INTERRUPT ENDPOINT EXPECTATIONS *********************************141 142 An interrupt endpoint is necessary to ensure that events are delivered143 in a predictable and timely manner.144 Event packets can be sent across USB with a guaranteed latency.145 146 The interrupt endpoint should have an interval of 1 ms (full speed).147 For a controller using USB high-speed the interrupt interval may have148 an interval of 125 microseconds.149 150 The USB software and firmware requires no intimate knowledge of the events151 passed to the host controller.152 153 ***************ISOCHRONOUS ENDPOINT EXPECTATIONS *******************************154 155 These isochronous endpoints transfer synchronous data to and from the host156 controller of the radio.157 158 Time is the critical aspect for this type of data.159 The USB firmware should transfer the contents of the data160 to the host controllers' synchronous FIFOs.161 If the FIFOs are full, the data should be overwritten with new data.162 These endpoints have a one (1) ms interval, as required by Chapter 9 of the163 USB Specification, Versions 1.0 and 1.1.164 165 A suggested max packet size for this endpoint would be at least 64 bytes.166 167 ********************** BLUETOOTH CODES *****************************************168 169 The following values are defined for Bluetooth Devices:170 171 Device/Inferface : USB Codes for Primary Controllers :172 Class bDeviceClass 0xE0 Wireless Controller173 Subclass bDeviceSubClass 0x01 RF Controller174 Protocol bDeviceProtocol 0x01 Bluetooth Pri Controller < bRequest : 0x00 >175 176 Device/Inferface : USB Codes for AMP Controllers :177 Class bDeviceClass 0xE0 Wireless Controller178 Subclass bDeviceSubClass 0x01 RF Controller179 Protocol bDeviceProtocol 0x04 Bluetooth AMP Controller < bRequest : 0x2B >180 181 These values should also be used in the interface descriptors for the interfaces182 183 Device : USB Codes for composite devices using IAD :184 Class bDeviceClass 0xEF Miscellaneous185 Subclass bDeviceSubClass 0x02 Common Class186 Protocol bDeviceProtocol 0x01 Interface Association Descriptor187 188 Interface : USB Codes for Primary Controllers :189 Class bDeviceClass 0xE0 Wireless Controller190 Subclass bDeviceSubClass 0x01 RF Controller191 Protocol bDeviceProtocol 0x01 Bluetooth Pri Controller < bRequest : 0x00 >192 193 Interface : USB Codes for AMP Controllers :194 Class bDeviceClass 0xE0 Wireless Controller195 Subclass bDeviceSubClass 0x01 RF Controller196 Protocol bDeviceProtocol 0x04 Bluetooth AMP Controller < bRequest : 0x2B >197 198 ************* BLUETOOTH COMPOSITE DEVICE IMPLEMENTATION ************************199 200 (IAD) : Interface Association Descriptors201 202 Example Interface Association Descriptor used for a Primary Controller function:203 204 Offset Field Size Value Description205 0 bLength 1 0x08 Size of this descriptor in octets206 1 bDescriptorType 1 0x0B INTERFACE ASSOCIATION DESCRIPTOR207 2 bFirstInterface 1 xxxx Interface number of the first interface associated with this device208 3 bInterfaceCount 1 0x02 Number of contiguous interfaces associated with the function209 4 bFunctionClass 1 0xE0 Wireless Controller210 5 bFunctionSubClass 1 0x01 RF Controller211 6 bFunctionProtocol 1 0x01 Bluetooth Primary Controller212 7 iFunction 1 xxxx Index Pointer to a name string for this function, if any is provide213 214 A USB Composite contains multiple independent functions. This section215 describes how to implement Bluetooth functions within a USB Composite216 device. This may require the use of Interface Association Descriptors (IAD) to217 aggregate multiple Interfaces. This also requires the host to address USB218 requests to the specific Interface219 220 A Primary Controller (ref) shall contain at least two interfaces:221 HCI Events and ACL data (3 endpoints)222 HCI SCO data (2 endpoints, multiple alternate settings)223 224 When used in a USB Composite device, a Primary Controller function shall use225 an IAD descriptor to associate the provided interfaces.226 227 When used in a USB Composite device, an AMP Controller does not need IAD.228 If the device contains the Device Firmware Upgrade option as a separate229 Device function, an IAD is not needed. If the Device Firmware Upgrade option230 is bundled with the AMP Controller function, then an IAD is needed to bind the231 two interfaces.232 233 A USB Composite device containing only a Primary Controller and an AMP Controller234 may include a Configuration Descriptor set with the following structure:235 236 Configuration Descriptor :237 238 0x09, 0x02, wTotalLength,239 0x03,240 // bNumInterfaces241 // IF#1 Primary events & ACL242 // IF#2 Primary SCO or eSCO243 // IF#3 AMP events & ACL244 0x01, // bConfigurationValue245 iConfiguration,246 bmAttributes,247 0xFA, // Max power used 500ma248 249 Interface Association Descriptor :250 251 0x08, 0x0B,252 IF#1, // bFirstInterface253 0x03, // bInterfaceCount : Number of contiguous interfaces associated with the function.254 0xE0, 0x01, 0x01, // Wireless Controller : RF Controller : Bluetooth Primary Controller255 iFunctionString256 257 INTERFACE DESCRIPTOR #1258 0x09, 0x04, IF#1, 0x00, 0x03, // bNumEndpoints : InterruptIn, BulkIn, BulkOut259 0xE0, 0x01, 0x01, // Wireless Controller : RF Controller : Bluetooth Primary Controller260 iInterfaceString261 262 ENDPOINT DESCRIPTOR : Interrupt, Bulk In, Bulk Out263 264 INTERFACE DESCRIPTOR #2265 266 0x09, 0x04, IF#2, 0x00, 0x02, // bNumEndpoints : Isoch OUT (SCO), Isoch IN (SCO)267 0xE0, 0x01, 0x01, // Wireless Controller : RF Controller : Bluetooth Primary Controller268 iInterfaceString269 270 ENDPOINT DESCRIPTOR : Iso In, Iso Out271 272 INTERFACE DESCRIPTOR #3273 274 0x09, 0x04, IF#3, 0x00, 0x03, // bNumEndpoints : Isoch OUT (SCO), Isoch IN (SCO)275 0xE0, 0x01, 0x04, // Wireless Controller : RF Controller : Bluetooth AMP Controller276 iInterfaceString277 278 ENDPOINT DESCRIPTOR : Interrupt, Bulk In, Bulk Out279 280 LOGICAL LINK CONTROL AND ADAPTATION PROTOCOL SPECIFICATION : L2CAP281 282 DATA PACKET FORMAT283 SIGNALING PACKET FORMATS284 285 SERVICE DISCOVERY PROTOCOL SPECIFICATION : SDP286 287 GENERIC ACCESS PROFILE288 289 AMP MANAGER PROTOCOL SPECIFICATION290 291 ATTRIBUTE PROTOCOL (ATT)292 293 GENERIC ATTRIBUTE PROFILE (GATT)294 295 SECURITY MANAGER SPECIFICATION296 297 */

转载地址:http://xiixx.baihongyu.com/

你可能感兴趣的文章
配置Eclipse使用maven构建项目默认JDK为1.8
查看>>
jsp内置对象以及jsp动作
查看>>
Struts上路_09-数据类型转换
查看>>
Android Eclipse 修改默认查看图片的打开方式
查看>>
CMake与动态链接库(dll, so, dylib)
查看>>
myeclipse(eclipse)乱码处理
查看>>
SpringBoot 过滤器, 拦截器, 监听器 对比及使用场景
查看>>
数据库索引探索
查看>>
struts2使用json需要注意的问题
查看>>
gitlab runner 优化
查看>>
快速添加百度网盘文件到Aria2 猴油脚本
查看>>
mac 无法登录mysql的解决办法
查看>>
Shiro权限判断异常之命名导致的subject.isPermitted 异常
查看>>
Hello world travels in cpp - 字符串(2)
查看>>
struts2自定义拦截器
查看>>
Eclipse安装adt插件后之后看不到andorid manger
查看>>
Kafka服务端脚本详解(1)一topics
查看>>
Zookeeper 集群安装配置,超详细,速度收藏!
查看>>
js中var self=this的解释
查看>>
js--字符串reverse
查看>>