蓝牙btsnoop log,HFP协议连接流程详解,以及RFCOMM连接和常用AT指令

HFP(Hands-Free):蓝牙免提协议,两个角色AG,HF端,AG端通常是手机设备,HF免提端一般为耳机车载等,hfp的连接首先要进行SDP,然后建立RFCOMM,然后SLC连接完成,HFP正式建立成功

inbandring tone:同步响铃功能,支持inbandring在电话响铃时会直接建立sco,通过sco播放手机端铃声,不支持inbandring则只会发ring给到耳机,播放自带铃声 叮叮叮~

SCO:区别于ACL,sco是另一条物理链路,用来同步传输实时语音数据

  1. HFP两个角色,音频网关AG端,HF免提端,在配对认证完成后L2CAP发起SDP,AG端去问询对端设备HF端支持的版本和features

  1. HFP建立连接需要在RFCOMM连接的基础上,L2CAP先发起RFCOMM的连接

3.RFCOMM帧类型:RFCOMM基于GSM TS 07.10,这是一种由GSM手机使用的一种非对称协议,可以将多个数据流复用到同一个物理串行电缆上。RFCOMM是对称的,使用TS 07.10特征帧和命令的子集通过L2CAP发送TS 07.10帧。TS 07.10的一些功能适用于蓝牙。

RFCOMM使用帧进行通信,RFCOMM帧作为L2CAP数据包中的有效负载数据。有五种不同的帧类型:

• SABM—Start Asynchronous Balanced Mode (startup command). 设置异步平衡模式

• UA—Unnumbered Acknowledgement (response when connected). 未编号的确认信息

• DISC—Disconnect (disconnect command). 断开连接

• DM—Disconnected Mode (response to a command when disconnected). 断开连接模式

• UIH—Unnumbered Information with Header check. 未编号的带校验头的信息

SABM, UA, DM和 DISC是底层的控制帧,RFCOMM使用信道,每个信道有一个数据连接链路标识(DLCI),UIH帧上的 DLCI = 0时用作发送控制信息, DLCI≠0时用作发送数据。

RFCOMM详细介绍:原文链接:RFCOMM简单介绍_cmax098的博客-CSDN博客

4.RFCOMM第一个控制帧是SABM,之后对端UA响应,UIH进行参数协商,然后第二帧SABM进行数据链路的连接,然后RFCOMM建立完成

5.基于RFCOMM的连接,HFP进行AT指令的交互,首先是AT+BRSF,HF端告诉AG端支持哪些features

EC and/or NR function: Supported (echo canceling and noise reduction functions)

AG端回声消除和噪音减弱, 可以通过AT+NREC= 0关闭

Call waiting or 3-way calling: Supported 三方电话

CLI presentation capability: Supported CLIP来电显示

Voice recognition activation: Supported 语音识别

Remote volume control: Supported 通话音量调节

Enhanced call status: Supported 电话状态

Enhanced call control: Not Supported

Codec negotiation: Supported 编码协商

HF Indicators: Supported

eSCO S4: Supported

6.+BRSF AG端回复HFP所支持features

Three-way calling: Supported

EC and/or NR function: Supported

Voice recognition function: Supported

In-band ring tone capability: Not Supported 同步响铃功能

Attach a number to a voice tag: Not Supported

Ability to reject a call: Supported

Enhanced call status: Supported

Enhanced call control: Not Supported

Extended error result codes: Supported

Codec negotiation: Supported

HF Indicators: Supported

eSCO S4: Supported

7.AT+BAC = 1,2. 通话sco支持的编码,cvsd 8k,msbc 16k

8.AT+CIND=? AT Command: Get supported indicators, 问询AG支持各种指示灯状态下的值范围

Indicators Supported

Call Status indicator:Values it can take: 0,1

Call Setup indicator:Range of values it can take: 0-3

Service availability indicator:Range of values it can take: 0-1

Signal indicator:Range of values it can take: 0-5

Roaming indicator:Values it can take: 0,1

Battery charge indicator:Range of values it can take: 0-5

Call Held indicator:Range of values it can take: 0-2

9.AT+CIND=? AT Command: Get indicators' status 问询当前AG端当前各个指示灯状态值

Indicator's Status

Call Status: No calls in progress

Call Setup: Not currently in call set up

Service availability: No service. No Home/Roam network available.

Signal indicator: Signal strength level 0

Roaming indicator: Roaming is not active

Battery charge indicator: Level 2

Call Held indicator: No calls held

10.AT+CMER=3, 0, 0, 1.Activates "indicator status reporting" 激活AG端通话状态报告

11.AT+CHLD=?.Retrieve "Three way calling" Info 获取AG端三方电话信息

12.AT+BIND = …,HF 告知 AG 其支持指示器特性

13.AT+BIND=? ,HF 向 AG 询问 AG 所支持的HF指示器信息

以上指令交互完成后,HFP SLC(service level connection)建立完成,HFP连接完成

14.其它常用AT指令

AT+NREC = 0 关闭回声消除和噪音减弱

AT+BIEV = *,* HF端蓝牙电量

AT+VGS = 12 (0-15) HF端speaker音量等级

AT+VGM = 12 (0-15) HF端mic送花音量等级

AT+CLIP = 1 开启来电显示

AT+CCWA = 1 AT Command: Enable call waiting notification

ATA 接听电话

AT+CHUP 挂断电话

AT+BCS = 2 sco编码协商时选择第二个编码msbc

.......

15.AG端ciev状态值

+CIEV:1,0 挂断电话或无活跃的通话

+CIEV:1,1 接听电话

+CIEV:2,0 当前没有等待的电话需要处理

+CIEV:2,2 拨打电话

+CIEV:2,3 已拨通

....

16.sco通话的建立流程

先AT+BCS进行编码协商

Command: HCI_Enhanced_Setup_Synchronous_Connection

Event: HCI_Synchronous_Connection_Complete

端开的话看对应连接的Connection_Handle

  • 7
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值