Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346412
  • 博文数量: 92
  • 博客积分: 2500
  • 博客等级: 少校
  • 技术积分: 960
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-21 19:38
文章分类

全部博文(92)

文章存档

2010年(71)

2009年(21)

我的朋友

分类: 嵌入式

2009-09-18 19:45:06

1.     HCI layer protocol overview:
HCI provides a uniform way to access the underlying Bluetooth. Shown:

 
It can be seen from the figure, Host Controller Interface (HCI) is used to communicate with Host and Module. Host is usually PC, Module is based on the various forms of physical connection (USB, serial, pc-card, etc.) to connect to the PC on a bluetooth Dongle.


In the side of Host: application, SDP, L2cap software, and other protocols are made in the form of software(Bluez is based on the kernel layer process). In the side of Module: Link Manager, BB, and other protocol are provided in hardware, in firmware.


The HCI was rather special, part of it is implemented in software, protocols and procedures used to provide access to the upper interface (Bluez in, hci.c hci_usb.c, hci_sock.c, etc.). The other part is implemented in the Firmware which is used to pass the instruction such to the underlying protocol.
 
The communication between the upper PC procedures and the lower modules is through HCI. There are four different forms of transmission :

Commands, Event, ACL Data, SCO / eSCO Data.

1.1. HCI Command:
HCI Command is the Host to send commands to Modules way. HCI Command Packet is structured as follows: 


 
OpCode is used to identify HCI Command. It consists of two parts, 10bit of Opcode Command. 6bit the Opcode Group.
 
1.1.1: OpCode Group:
Linux Kernel (BlueZ) in, ~ / include / net / bluetooth / hci.h defined OpCode Group.
# define OGF_LINK_CTL 0x01
# define OGF_LINK_POLICY 0x02
# define OGF_HOST_CTL 0x03
# define OGF_INFO_PARAM 0x04
# define OGF_STATUS_PARAM 0x05
They represent a variety of Command Group:
 
OGF_LINK_CTL: Link control, the Command Group of the Command to allow Host Control and other bluetooth device connection.
OGF_LINK_POLICY: Link Policy. The Command Group of the Command to allow adjustment of Link Manager control.
OGF_HOST_CTL: Control and Baseband.
 
1.1.2: Opcode Command:
Group 1 is used in the same unique identifier within the Command. ~ /include/net/bluetooth/hci.h defined.
 
 
1.2: HCI Event:
Modules send some information to the Host by using HCI Event. Event Packet is structured as follows:


 
HCI Event 3 types: Command complete Event, Command States Event, Command Subsequently Completend.


Command complete Event: If the Host sends a Command results can immediately, it will send such Event. In other words, if the Command sent only to the local Modules related and not deal with the remote device, use the Command complete Event. For example: HCI_Read_Buffer_Size.


Command States Event: If the Host sends the Command can not immediately know the results, then the sending of such Event. Host send Command carried out in order to deal with the Remote device, you must not immediately know the results, they will send Command States Event. For example:
HCI Connect.


Command Subsequently Completend: Command delayed the completion of Event. For example: Connection has been established.
 
The following figure is a Command-Event examples:

 


 
From this figure you can see, if the Host sends the Command relevant to the Remote device, it will first send Command States Event. When movements are actually completed, and then send the Command Subsequently Completend.
 
The following diagram shows l2cap data how pass to the underlying protocol step by step.

 
Obviously, a l2cap packet will follow the rules and cut into several HCI packets. HCI data packets is passed to the USB device through the HCI-usb layer. Each package also sent to the bottom through the USB driver.
 

 

阅读(2014) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~