BLUETOOTH SPECIFICATION Version 4.2 [Vol 1, Part A] page 63
The asynchronous connection-oriented (ACL) logical transport is used to carry LMP and L2CAP control signaling and best effort asynchronous user data. The ACL logical transport uses a 1-bit ARQN/SEQN scheme to provide simple channel reliability. Every active slave device within a piconet has one ACL logical transport to the piconet master, known as the default ACL.
#请求ACL连接 > 326 21.946869 controller host HCI_EVT 13 Rcvd Connect Request --------------------------------------------------------------------------- Bluetooth HCI Event - Connect Request Event Code: Connect Request (0x04) Parameter Total Length: 10 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Class of Device: 0x5a020c (Phone:Smartphone - services: Networking Capturing ObjectTransfer Telephony) Link Type: ACL connection (Data Channels) (0x01)
#允许ACL连接 > 327 21.947178 host controller HCI_CMD 11 Sent Accept Connection Request --------------------------------------------------------------------------- Bluetooth HCI Command - Accept Connection Request Command Opcode: Accept Connection Request (0x0409) Parameter Total Length: 7 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Role: Remain the Slave for this connection. The LM will NOT perform the role switch. (0x01) [Pending in frame: 328] [Command-Pending Delta: 0.685ms] [Response in frame: 329] [Command-Response Delta: 4.432ms]
> 1214 47.023224 host controller HCI_CMD 17 Sent Create Connection --------------------------------------------------------------------------- Bluetooth HCI Command - Create Connection Command Opcode: Create Connection (0x0405) Parameter Total Length: 13 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Packet Type: 0xcc18, DH5, DM5, DH3, DM3, DH1, DM1 Page Scan Repetition Mode: R1 (0x01) Page Scan Mode: Mandatory Page Scan Mode (0x00) .011 1001 0100 0100 = Clock Offset: 0x3944 (18325 msec) 1... .... .... .... = Clock_Offset_Valid_Flag: true (1) Allow Role Switch: Local device may be master, or may become slave after accepting a master slave switch. (0x01) [Pending in frame: 1215] [Command-Pending Delta: 1.458ms] [Response in frame: 1217] [Command-Response Delta: 1630.81ms]
> 1216 48.646874 controller host HCI_EVT 11 Rcvd Role Change --------------------------------------------------------------------------- Bluetooth HCI Event - Role Change Event Code: Role Change (0x12) Parameter Total Length: 8 Status: Success (0x00) BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Role: Currently the Slave for specified BD_ADDR (0x01)
> 1900 62.151696 controller host HCI_EVT 13 Rcvd Connect Request --------------------------------------------------------------------------- Bluetooth HCI Event - Connect Request Event Code: Connect Request (0x04) Parameter Total Length: 10 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Class of Device: 0x5a020c (Phone:Smartphone - services: Networking Capturing ObjectTransfer Telephony) Link Type: ACL connection (Data Channels) (0x01)
> 1901 62.152042 host controller HCI_CMD 11 Sent Accept Connection Request --------------------------------------------------------------------------- Bluetooth HCI Command - Accept Connection Request Command Opcode: Accept Connection Request (0x0409) Parameter Total Length: 7 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Role: Remain the Slave for this connection. The LM will NOT perform the role switch. (0x01) [Pending in frame: 1902] [Command-Pending Delta: 0.748ms] [Response in frame: 1903] [Command-Response Delta: 4.455ms]
> 1968 62.415419 controller host HCI_EVT 9 Rcvd Link Key Request --------------------------------------------------------------------------- Bluetooth HCI Event - Link Key Request Event Code: Link Key Request (0x17) Parameter Total Length: 6 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00)
> 1969 62.415629 host controller HCI_CMD 26 Sent Link Key Request Reply --------------------------------------------------------------------------- Bluetooth HCI Command - Link Key Request Reply Command Opcode: Link Key Request Reply (0x040b) Parameter Total Length: 22 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Link Key: 2160acf6b7403a97050f64de72570b1d [Response in frame: 1971] [Command-Response Delta: 0.934ms]
> 1971 62.416563 controller host HCI_EVT 13 Rcvd Command Complete (Link Key Request Reply) --------------------------------------------------------------------------- Bluetooth HCI Event - Command Complete Event Code: Command Complete (0x0e) Parameter Total Length: 10 Number of Allowed Command Packets: 1 Command Opcode: Link Key Request Reply (0x040b) Status: Success (0x00) BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) [Command in frame: 1969] [Command-Response Delta: 0.934ms]
SCO
BLUETOOTH SPECIFICATION Version 4.2 [Vol 1, Part A] page 64
The synchronous connection-oriented (SCO) logical transport is a symmetric, point-to-point transport between the master and a specific slave. The SCO logical transport reserves slots on the physical channel and can therefore be considered as a circuit-switched connection between the master and the slave. SCO logical transports carry 64 kb/s of information synchronized with the piconet clock. Typically this information is an encoded voice stream. Three different SCO configurations exist, offering a balance between robustness, delay and bandwidth consumption.
BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part B] page 222
The service discovery mechanism provides the means for client applications to discover the existence of services provided by server applications as well as the attributes of those services. The attributes of a service include the type or class of service offered and the mechanism or protocol information needed to utilize the service.
> 455 22.824346 localhost () XiaomiCo_6e:38:c5 (PHONE) SDP 29 Sent Service Search Attribute Request : L2CAP: Attribute Range (0x0000 - 0xffff) --------------------------------------------------------------------------- Frame 455: 29 bytes on wire (232 bits), 29 bytes captured (232 bits) Bluetooth Bluetooth HCI H4 Bluetooth HCI ACL Packet Bluetooth L2CAP Protocol Bluetooth SDP Protocol PDU: Service Search Attribute Request (0x06) Transaction Id: 0x0000 Parameter Length: 15 Service Search Pattern: L2CAP Maximum Attribute Byte Count: 1008 Attribute ID List Data Element: Sequence uint8 5 bytes 0011 0... = Data Element Type: Sequence (6) .... .101 = Data Element Size: uint8 (5) Data Element Var Size: 5 Data Value Data Element: Unsigned Integer 4 bytes 0000 1... = Data Element Type: Unsigned Integer (1) .... .010 = Data Element Size: 4 bytes (2) Data Value Attribute Range: 0x0000ffff Attribute Range From: 0x0000 Attribute Range To: 0xffff Continuation State: no (00)
> 471 22.896191 XiaomiCo_6e:38:c5 (PHONE) localhost () SDP 281 Rcvd Service Search Attribute Response --------------------------------------------------------------------------- Frame 471: 281 bytes on wire (2248 bits), 281 bytes captured (2248 bits) Bluetooth Bluetooth HCI H4 Bluetooth HCI ACL Packet Bluetooth L2CAP Protocol Bluetooth SDP Protocol PDU: Service Search Attribute Response (0x07) Transaction Id: 0x0001 Parameter Length: 267 Attribute List Byte Count: 264 Data Fragment Continuation State: no (00) [Reassembled Attribute List] Attribute Lists [count = 14] Data Element: Sequence uint16 1269 bytes 0011 0... = Data Element Type: Sequence (6) .... .110 = Data Element Size: uint16 (6) Data Element Var Size: 1269 Data Value Attribute List [count = 4] (Generic Attribute Profile) Attribute List [count = 4] (Generic Access Profile) Attribute List [count = 6] (Headset Audio Gateway) Attribute List [count = 8] (Handsfree Audio Gateway) Attribute List [count = 8] (A/V Remote Control Target) Attribute List [count = 7] (Audio Source) Attribute List [count = 11] (PAN NAP) Attribute List [count = 9] (PAN PANU) Attribute List [count = 7] (Phonebook Access Server) Attribute List [count = 10] (Message Access Server) Attribute List [count = 4] (Xiaomi Inc.) Attribute List [count = 5] (CustomUUID: Unknown) Attribute List [count = 8] (OBEX Object Push) Attribute List [count = 4] (Unknown)
<value>=0 implies no service. No Home/Roam network available.
<value>=1 implies presence of service. Home/Roam network available.
call: Standard call status indicator:
<value>=0 means there are no calls in progress
<value>=1 means at least one call is in progress
callsetup: Bluetooth proprietary call set up status indicator4. Support for this indicator is optional for the HF. When supported, this indicator shall be used in conjunction with, and as an extension of the standard call indicator. Possible values are as follows:
<value>=0 means not currently in call set up.
<value>=1 means an incoming call process ongoing.
<value>=2 means an outgoing call set up is ongoing.
<value>=3 means remote party being alerted in an outgoing call.
callheld: Bluetooth proprietary call hold status indicator. Support for this indicator is mandatory for the AG, optional for the HF. Possible values are as follows:
0= No calls held
1= Call is placed on hold or active/held calls swapped (The AG has both an active AND a held call)
Call on hold, no active call
signal: Signal Strength indicator:
<value>= ranges from 0 to 5
roam: Roaming status indicator:
<value>=0 means roaming is not active
<value>=1 means a roaming is active
battchg: Battery Charge indicator of AG:
<value>=ranges from 0 to 5
+CIND:当前indicator的列表
AT+CLCC:列出当前电话命令,
+CLCC:当前call结果码,支持参数是
idx:表示建立连接顺序或者接听电话的数字(从1开始)。
dir:0(outgoing),1(incoming)
status:
0=Active
1=Held
2=Dialing(outgoing calls only)
3=Alerting(outgoing calls only)
4=Incoming(incoming calls only)
5=Waiting(incoming calls only)
6 = Call held by Response and Hold
mode= 0 (Voice), 1 (Data), 2 (FAX)
mpty=
0 - this call is NOT a member of a multi-party (conference) call
1 - this call IS a member of a multi-party (conference) call
number (optional)
type (optional)
AT+COPS: AT+COPS=3,0将被HF发送给AG
AT+CMEE: 使能+CME ERROR: 结果码
+CME ERROR
+CME ERROR: 0 – AG failure
AT+CLIP: Calling Line Identification notification 使能命令,It enables/disables the Calling Line Identification notification unsolicited result code 。
+CLIP : Standard “Calling Line Identification notification” unsolicited result code.
AT+CMER :Standard event reporting activation/deactivation AT command.
+CIEV: “indicator events reporting”结果码。<ind>,<value> result code ,对应AT+CIND 返回的列表中的参数和值。
AT+VTS: DTMF生成命令。
AT+CNUM: HF相应+CNUM命令
AT+CNUM (Retrieve Subscriber Number Information)
AT+CNUM=? (Test Subscriber Number Information – Not Implemented)
+CNUM: 用于将“ Subscriber Number Information ”从AG发送到HF的标准响应。
HFP协议扩展的AT命令:
AT+BIA (Bluetooth Indicators Activation)
AT+BINP (Bluetooth INPut)
AT+BLDN (Bluetooth Last Dialed Number)
AT+BVRA (Bluetooth Voice Recognition Activation)
+BVRA (Bluetooth Voice Recognition Activation)
AT+BRSF (Bluetooth Retrieve Supported Features)
+BRSF (Bluetooth Retrieve Supported Features)
AT+NREC (Noise Reduction and Echo Canceling)
AT+VGM (Gain of Microphone)
AT+VGS (Gain of Speaker)
+VGM (Gain of Microphone)
+VGS (Gain of Speaker)
+BSIR (Bluetooth Setting of In-band Ring tone)
AT+BTRH (Bluetooth Response and Hold Feature)
+BTRH (Bluetooth Response and Hold Feature)
AT+BCC (Bluetooth Codec Connection)
AT+BCS (Bluetooth Codec Selection)
+BCS (Bluetooth Codec Selection)
AT+BAC (Bluetooth Available Codecs)
AT+BIND (Bluetooth HF Indicators Feature)
+BIND (Bluetooth HF Indicators Feature)
AT+BIEV (Bluetooth HF Indicators Feature)
建立服务连接
Upon a user action or an internal event, either the HF or the AG may initiate a Service Level Connection establishment procedure. A Service Level Connection establishment requires the existence of a RFCOMM connection, that is, a RFCOMM data link channel between the HF and the AG. Both the HF and the AG may initiate the RFCOMM connection establishment. If there is no RFCOMM session between the AG and the HF, the initiating device shall first initialize RFCOMM.
连接过程如下:
支持能力交换 首先HF发送AT+BRSF=< HF supported features >给AG,目的是首先通知AG其具有的能力,其次接收AG返回的其自身的BRSF能力。
Codec协商 如果HF支持Codec Negotiation特征,其会查看AG返回的BRSF中是否也支持该特性,如果都支持该特性,则HF将发送AT+BAC=< HF available codecs >命令给AG以告知其可用的codec。
当且仅当SDP服务发现AH和AG双方均支持"Call waiting and 3-way calling",在HFAG通过AT+CHLD命令发来的其对呼叫等待和多方电话的支持,对这种情况,"HF indicator"不要设置该比特位,AG也不要在+BRSF命令中设置该比特位。
在HF使用AT+CMER命令成功启用“Indicator status update”功能,对这种情况SDP服务不应该设置“Call waiting and 3-way calling”比特位。 如果HF收到AG通过indicator指示当前有电话时,HF查询AG的接听和保持状态来判断是否是未接听电话。
#判断是否支持"Call waiting and 3-way calling" #AG发现HF, hfP支持的协议,HF支持"Call waiting and 3-way calling" > 596 17.850811 XiaomiCo_6e:38:c5 (PHONE) SANYOEle_62:35:bb (DEVICE) SDP 36 Rcvd Service Search Attribute Request : Handsfree: [Service Class ID List 0x0001] [Protocol Descriptor List 0x0004] [Bluetooth Profile Descriptor List 0x0009] [(HFP HS) Supported Features 0x0311] > 597 17.851437 SANYOEle_62:35:bb (DEVICE) XiaomiCo_6e:38:c5 (PHONE) SDP 69 Sent Service Search Attribute Response --------------------------------------------------------------------------- Bluetooth SDP Protocol PDU: Service Search Attribute Response (0x07) Transaction Id: 0x0000 Parameter Length: 55 Attribute List Byte Count: 52 Attribute Lists [count = 1] Data Element: Sequence uint8 50 bytes 0011 0... = Data Element Type: Sequence (6) .... .101 = Data Element Size: uint8 (5) Data Element Var Size: 50 Data Value Attribute List [count = 4] (Handsfree) Data Element: Sequence uint16 47 bytes 0011 0... = Data Element Type: Sequence (6) .... .110 = Data Element Size: uint16 (6) Data Element Var Size: 47 Data Value Service Attribute: Service Class ID List (0x1), value = Handsfree -> Generic Audio Service Attribute: Protocol Descriptor List (0x4), value = L2CAP -> RFCOMM:2 Service Attribute: Bluetooth Profile Descriptor List (0x9), value = Handsfree 1.6 Service Attribute: (HFP HS) Supported Features (0x311), value = (EC and/or Nr Function) (Call Waiting or Three Way Calling) (CLI Presentation Capability) (Voice Recognition Activation) (Remote Volume Control) (Wide Band Speech) Continuation State: no (00)
#HF发现AG, hfP支持的协议,AG不支持"Call waiting and 3-way calling",只支持"3-way calling" > 637 18.017460 SANYOEle_62:35:bb (DEVICE) XiaomiCo_6e:38:c5 (PHONE) SDP 33 Sent Service Search Attribute Request : Handsfree Audio Gateway: [Service Class ID List 0x0001] [Bluetooth Profile Descriptor List 0x0009] [(HFP AG) Supported Features 0x0311] > 644 18.024689 XiaomiCo_6e:38:c5 (PHONE) SANYOEle_62:35:bb (DEVICE) SDP 52 Rcvd Service Search Attribute Response --------------------------------------------------------------------------- Bluetooth SDP Protocol PDU: Service Search Attribute Response (0x07) Transaction Id: 0x0000 Parameter Length: 38 Attribute List Byte Count: 35 Attribute Lists [count = 1] Data Element: Sequence uint8 33 bytes 0011 0... = Data Element Type: Sequence (6) .... .101 = Data Element Size: uint8 (5) Data Element Var Size: 33 Data Value Attribute List [count = 3] (Handsfree Audio Gateway) Data Element: Sequence uint16 30 bytes 0011 0... = Data Element Type: Sequence (6) .... .110 = Data Element Size: uint16 (6) Data Element Var Size: 30 Data Value Service Attribute: Service Class ID List (0x1), value = Handsfree Audio Gateway -> Generic Audio Service Attribute: Bluetooth Profile Descriptor List (0x9), value = Handsfree 1.6 Service Attribute: (HFP AG) Supported Features (0x311), value = (Three Way Calling) (EC and/or Nr Function) (Voice Recognition Function) (Wide Band Speech) Continuation State: no (00)
#标志HFP连接建立 #启用"Indicator status update" > 658 18.093591 SANYOEle_62:35:bb (DEVICE) XiaomiCo_6e:38:c5 (PHONE) HFP 30 Sent AT+CMER=3,0,0,1 > 660 18.117156 XiaomiCo_6e:38:c5 (PHONE) SANYOEle_62:35:bb (DEVICE) HFP 20 Rcvd OK
HF拨打\挂断电话
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#HF拨打电话 > 921 29.433324 SANYOEle_62:35:bb (DEVICE) XiaomiCo_6e:38:c5 (PHONE) HFP 24 Sent ATD10086; --------------------------------------------------------------------------- Bluetooth HFP Profile [Role: HS - Headset (2)] AT Stream: ATD10086;\r Command 0: D Command Line Prefix: AT Command: D (Dial) [Expert Info (Warning/Protocol): Non mandatory type or command in this role] Parameters: No > 924 30.778650 XiaomiCo_6e:38:c5 (PHONE) SANYOEle_62:35:bb (DEVICE) HFP 20 Rcvd OK
> 925 30.779082 SANYOEle_62:35:bb (DEVICE) XiaomiCo_6e:38:c5 (PHONE) HFP 22 Sent AT+CLCC > 929 30.820871 XiaomiCo_6e:38:c5 (PHONE) SANYOEle_62:35:bb (DEVICE) HFP 46 Rcvd +CLCC: 1,0,2,0,0,"10086",129 --------------------------------------------------------------------------- Bluetooth HFP Profile [Role: AG - Audio Gate (1)] AT Stream: \r\n+CLCC: 1,0,2,0,0,"10086",129\r\n Command 0: +CLCC Command: +CLCC (Current Calls) Type: Response (0x003a) Parameters ID: 1 Direction: Mobile Originated (0) State: Dialing (2) Mode: Voice (0) Mpty: Call is not one of multiparty (conference) call parties (0) Number: "10086" Type: The phone number format may be a national or international format, and may contain prefix and/or escape digits. No changes on the number presentation are required. (129)
AG下发通话状态
在开启"Indicator status update"(AT+CMER)之后,AG会主动下发当前的通话状态,Indicator Index对应+CIND返回的参数列表,Indicator <idx>对应其值。
#AG请求建立eSCO连接 > 906 387.530834 controller host HCI_EVT 13 Rcvd Connect Request --------------------------------------------------------------------------- Bluetooth HCI Event - Connect Request Event Code: Connect Request (0x04) Parameter Total Length: 10 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Class of Device: 0x001f00 (Uncategorized: device code not specified:Unknown - services:) Link Type: eSCO connection (Voice Channels) (0x02)
#HF允许建立eSCO连接 > 907 387.531078 host controller HCI_CMD 67 Sent Enhanced Accept Synchronous Connection Request --------------------------------------------------------------------------- Bluetooth HCI Command - Enhanced Accept Synchronous Connection Request Command Opcode: Enhanced Accept Synchronous Connection Request (0x043e) 0000 01.. .... .... = Opcode Group Field: Link Control Commands (0x01) .... ..00 0011 1110 = Opcode Command Field: Enhanced Accept Synchronous Connection Request (0x03e) Parameter Total Length: 63 BD_ADDR: XiaomiCo_6e:38:c5 (00:00:00:00:00:00) Tx Bandwidth (bytes/s): 8000 Rx Bandwidth (bytes/s): 8000 Transmit Coding Format Receive Coding Format Transmit Codec Frame Size: 60 Receive Codec Frame Size: 60 Input Bandwidth: 16000 Output Bandwidth: 16000 Input Coding Format Output Coding Format Input Coded Data Size: 16 Output Coded Data Size: 16 Input PCM Data Format: 2's complement (0x02) Output PCM Data Format: 2's complement (0x02) Input PCM Sample Payload MSB Position: 0 Output PCM Sample Payload MSB Position: 0 Input Data Path: Vendor Specific Output Data Path: Vendor Specific Input Transport Unit Size: 16 Output Transport Unit Size: 16 Max. Latency (ms): 12 Packet Type: 0x03bf, 3-EV5 may NOT be used, 2-EV5 may NOT be used, 3-EV3 may NOT be used, EV5 may be used, EV4 may be used, EV3 may be used, HV3 may be used, HV2 may be used, HV1 may be used Retransmission Effort: At least 1 retransmission, optimize for link quality (2) [Pending in frame: 909] [Command-Pending Delta: 1.38ms] [Response in frame: 910] [Command-Response Delta: 3.862ms]
#发现 > 134 0.964749 localhost () XiaomiCo_6e:38:c5 (PHONE) SDP 33 Sent Service Search Attribute Request : Audio Source: [Service Class ID List 0x0001] [Protocol Descriptor List 0x0004] [Bluetooth Profile Descriptor List 0x0009] > 139 0.981837 XiaomiCo_6e:38:c5 (PHONE) localhost () SDP 64 Rcvd Service Search Attribute Response --------------------------------------------------------------------------- Bluetooth SDP Protocol PDU: Service Search Attribute Response (0x07) Transaction Id: 0x0000 Parameter Length: 50 Attribute List Byte Count: 47 Attribute Lists [count = 1] Data Element: Sequence uint8 45 bytes 0011 0... = Data Element Type: Sequence (6) .... .101 = Data Element Size: uint8 (5) Data Element Var Size: 45 Data Value Attribute List [count = 3] (Audio Source) Data Element: Sequence uint16 42 bytes 0011 0... = Data Element Type: Sequence (6) .... .110 = Data Element Size: uint16 (6) Data Element Var Size: 42 Data Value Service Attribute: Service Class ID List (0x1), value = Audio Source Attribute ID: Service Class ID List Value Service Attribute: Protocol Descriptor List (0x4), value = L2CAP:25 -> AVDTP (1.3) Attribute ID: Protocol Descriptor List Value Service Attribute: Bluetooth Profile Descriptor List (0x9), value = Advanced Audio Distribution 1.3 Attribute ID: Bluetooth Profile Descriptor List Value Continuation State: no (00)
from PyQt5 import QtCore from PyQt5 import QtWebEngineWidgets from PyQt5.QtCore import QDir from PyQt5.QtWebChannel import QWebChannel from PyQt5.QtWebEngineWidgets import QWebEngineView from PyQt5.QtWidgets import *
exportdefaultclassLaunchextendsComponent { render() { return ( <Viewstyle={styles.container}> <Textstyle={styles.welcome}> Welcome to React Native! </Text> <Textstyle={styles.instructions}> To get started, edit index.js </Text> <Textstyle={styles.instructions}> Double tap R on your keyboard to reload,{'\n'} Shake or press menu button for dev menu </Text> </View> ); } }
Scanning 564 folders for symlinks in x:\xxxx\React\node_modules (43ms) ┌──────────────────────────────────────────────────────────────────────────── ┐ │ Running packager on port 8081. │ │ │ │ Keep this packager running while developing on any JS projects. Feel │ │ free to close this tab and run your own packager instance if you │ │ prefer. │ │ │ │ https://github.com/facebook/react-native │ │ │ └────────────────────────────────────────────────────────────────────────────┘ Looking for JS files in X:\xxxx\React React packager ready.