📄 arm平台上蓝牙协议栈bluez的移植使用和配置 - colorant的专栏 - csdn博客.htm
字号:
lang=EN-US><FONT face="Times New Roman">Bluez</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,只要你的内核版本不是太旧,无需打</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Patch</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,直接配置好就</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">OK</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">了,内核里面的代码相对比较稳定了。当然,</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Bluez</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对一些</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Bluetooth</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">协议栈新特性的支持,还是需要更新</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">kernel</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">代码的。你应该确认你使用的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">kernel</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本是否以及包含了对应的支持。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">内核的配置,基本上把</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> networking</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">下</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> --- Bluetooth subsystem support
</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里的以下几项全部选上即可:</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>L2CAP protocol support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>SCO links support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>RFCOMM protocol support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>RFCOMM TTY support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>BNEP protocol support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>HIDP protocol support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此外,在</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Bluetooth device
drivers</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">里选上你所需要支持的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Bluetooth</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设备。我使用的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">CSR</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">chip</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">是我们直接</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">build</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在板子上,通过串口和</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">cpu</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">通讯的,芯片默认使用</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">BCSP</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">作为通讯协议,所以我选择了:</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>HCI UART driver</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt 21pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>BCSP protocol support</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果你是通过</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">usb</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">接口使用蓝牙适配器,需要选择</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt 21pt"><SPAN lang=EN-US><FONT
face="Times New Roman" size=3>HCI USB driver</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt 21pt"><SPAN
lang=EN-US><O:P><FONT face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<H2 style="MARGIN: 0cm 0cm 0pt 31.2pt"><FONT face="Times New Roman"><SPAN
lang=EN-US style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore">2.2<SPAN style="FONT: 7pt 'Times New Roman'"><FONT
size=5>
</FONT></SPAN></SPAN></SPAN><SPAN lang=EN-US>Bluez Lib /
Utils</SPAN></FONT></H2>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
lang=EN-US><FONT face="Times New Roman">Bluez Lib</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的编译比较简单,而</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Bluez-Utils</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">所依赖的库就比较多了,大体包括</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> dbus alsa hal gstreamer openobex
xml</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等等,仔细观察</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">./configure </FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的输出,将所需要的包先安装或者</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">build</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">好。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'"><FONT
size=3>值得注意的一点是:</FONT></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果你需要打开所有的功能模块的支持,需要在</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> ./configure </FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">参数中添加</SPAN><FONT
face="Times New Roman"> <SPAN lang=EN-US>--enable-all <SPAN
style="mso-spacerun: yes"> </SPAN>--enable-audio --enable-input
--enable-network –enable-serial </SPAN></FONT><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等,在</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">3.22</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">版本中</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> --enable-all </FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">居然不包括</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> audio</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等相关模块的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">service</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的编译,不知道是否是因为还保留了</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">daemon</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">和</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">service</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等不同方案的缘故。不过,这至少与他的</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">configure --help </FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对于</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman"> --enable-all </FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的描述是不符合的。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<H1 style="MARGIN: 0cm 0cm 0pt 24.1pt"><SPAN lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore"><FONT face="Times New Roman">3<SPAN
style="FONT: 7pt 'Times New Roman'"><FONT
size=6>
</FONT></SPAN></FONT></SPAN></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">蓝牙硬件初始化及基础服务启动</SPAN></H1>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><FONT size=3><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">如果在</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">PC</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">环境下,使用</SPAN><SPAN
lang=EN-US><FONT face="Times New Roman">Ubuntu</FONT></SPAN><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">,调用</SPAN><FONT
face="Times New Roman"> <SPAN lang=EN-US>/etc/init.d/bluetooth start
</SPAN></FONT><SPAN
style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">应该就能完成这一步的工作了。下面叙述一下在我的嵌入式环境下,如何手动完成这一步骤。</SPAN></FONT></P>
<P class=MsoNormalIndent style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><O:P><FONT
face="Times New Roman" size=3></FONT></O:P></SPAN></P>
<H2 style="MARGIN: 0cm 0cm 0pt 31.2pt"><SPAN lang=EN-US
style="mso-fareast-font-family: 'Times New Roman'"><SPAN
style="mso-list: Ignore"><FONT face="Times New Roman">3.1<SPAN
style="FONT: 7pt 'Times New Roman'"><FONT
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -