1、蓝牙耳机编程流程HANDESET Programmers Guide蓝牙耳机编程流程-HANDESET Programmers GuideHANDESET Programmers Guide 洪林整理 HANDESET Programmers Guide 1. Introduction Headset profile is used to enable wireless connectivity among Bluetooth enabled Headsets, PCs and the cellular phones. 2. Concepts 2.1 USAGE (用法) Two use ca
2、ses are presented here for understanding the AG and HS roles. Note that these cases are not comprehensive. Incoming call 1 Incoming call arrives at a cellular phone connected to a mobile network. 2 The cellular phone acting as an AG indicates this call arrival to a Headset. This is typically perceiv
3、ed as a ring on the HS. 3 The user accepts the incoming call, by pressing a button on the HS. 第 1 页 共 20 页 HANDESET Programmers Guide 洪林整理 4 The AG on receiving this acceptance routes the audio data from the network to HS. Outgoing call 1 An user dials a number using a cellular phone (AG). 2 Upon su
4、ccessful connection, the user by pressing a button on the HS initiates a transfer of the audio data from the cell phone to the HS. Note: 1 Headsets typically have a user interface by which intentions such as call accept, call transfer are indicated to the AG. 2 The word button used above is a simile
5、 for any such user interface 3 IMPORTANT: Although the word call is frequently used in this document, it shall be read as Audio connection. This is because the AG may treat the HS as the input or output audio port for purposes other than call processing (such as tunes, beeps, alarms, etc.). 2.2 控制路径
6、和数据路径 1, A Control path typically transmits commands and responses relating to a profile and the Data path is typically used to transmit voice data 2A Control path should be established prior to the establishment of the Data path. 3 The existence of a Data path is optional 4. In the context of the H
7、eadset profile commands and responses relating to call acceptance, audio data transfer, volume control etc. are exchanged between the AG and HS over the Control path and the Data path is used to transfer audio (voice) data between the AG and the HS 2.3 MODULE The profile implementation consists of t
8、hree modules. These are outlined below. This provides the serial port interface that both HS and AG use to SPChannel establish/release Control and Data paths. (See SPChannel programmers guide for details). Implementation of the HS portion of the profile; used by applications Headset (HS) residing on
9、 the HS. Implementation of the AG portion of the profile; used by applications Audio-Gateway (AG) residing on the AG. 第 2 页 共 20 页 HANDESET Programmers Guide 洪林整理 2.4 Application state The Headset API is stateless in nature. This means that the application has to keep track of states. The possible s
10、tates of an application (with respect to the Headset profile) are typically State Description NOT Here the Control path is not established. CONNECTED Here the Control path is established but the Data path CONNECTED is not. The Data path is also established here and is being used IN_CALL to stream vo
11、ice the AG to the HS. 2.5 Establishment and release of Control and Data paths The following matrix specifies the correlation between the Control/Data paths and the roles as per the Headset profile specification. Action Establish Release Control HS or AG AG Path Data AG AG 第 3 页 共 20 页 HANDESET Progr
12、ammers Guide 洪林整理 i.e. 1 The Control path can be established either by the HS or AG while its release can be performed only by the AG. 2 The Data path can be established and released only by the AG 2.6 SPChannel API The SPChannel API that provides a means to establish and release Control and Data pa
13、ths is used by the Headset API. The reader is recommended to read the SPChannel programmers guide before proceeding further. 2.7 Headset API usage From the HS end HS initialization To accept an incoming call. To transfer the call from the AG to the HS. To terminate the call. To notify AG about speak
14、er and microphone volume levels. Proprietary commands HS un-initialization Note that the HS initialization and un-initialization are not necessarily requirements but have been included here for the sake of completeness of the API usage. From the AG end AG initialization To notify the HS of an incomi
15、ng call. To transfer the call from the HS to the AG. To control the speaker and microphone volume levels of the HS. Proprietary unsolicited result codes AG un-initialization 2.8 Button press handling The Headset specification uses the word User initiated action to mean an indication received from th
16、e user (typically a button press, or a GUI click etc.) to perform a suitable action. The 第 4 页 共 20 页 HANDESET Programmers Guide 洪林整理 suitable action in the context HS in the Headset specification is either a call accept, call transfer or call terminate. Thus the same User initiated action that is c
17、onveyed by the HS to the AG is interpreted differently. This is based on the states of the HS and AG applications that are currently interaction with each other. The HS_SendButtonPress function of the HS API is used to model this Use initiated action. We shall now look at what it means to handle the
18、 button press at the Headset end and Gateway end 3. Requirements The requirements on the HS and AG units of this profile are stated in the table below. Requirement Description Ability to establish a connection in order to treat the Incoming audio connection HS as an output audio port of the AG. Abil
19、ity to establish a connection in order to treat the Outgoing audio connection HS as an input audio port of the AG. Audio connection transfer Transferring the audio between the HS and AG. Remote audio volume control Ability of the AG to adjust the volume level on the HS. 4. API Usage This section pre
20、sents the usage of headset (HS and AG) API function. Example use case scenarios are presented here to highlight API usage. 4.1 Usage of HS API The usage of the HS API is presented in the following sections. 第 5 页 共 20 页 HANDESET Programmers Guide 洪林整理 4.1.1 HS initialization The HS application must
21、first initialize the HS profile. This is done as follows: Establish a SPChannel Control path Use the active (established) SPChannel handle to create (initialize) the HS_Handle. This HF_Handle will be used in all the other calls of the HS API. Note that whether the application is listening or connect
22、ing, successful establishment of a Control path will be indicated using the spchannel_open_cfm callback. 4.1.2 To accept an incoming call (I) Here we present the case on how the HS accepts an incoming call. This is accomplished as follows: HS waits for an incoming Control path establishment by the A
23、G. HS receives the RING code on the Control path that indicates that the HS could perform a local ring on the headphone that there is a incoming call User at HS presses a button to signal call acceptance of the incoming call. This signal is sent to the AG. HS receives a confirmation (response) from
24、the AG for the call accept. HS receives a Data path establishment indication (the Data path being initiated by the AG). Voice data is received on the Data path and rendered on the headphone appropriately. 第 6 页 共 20 页 HANDESET Programmers Guide 洪林整理 4.1.3 To accept an incoming call (II) Here we pres
25、ent another case by which the HS accepts an incoming call. This is accomplished as follows: HS waits for an incoming Control path establishment by the AG. HS receives the RING code on the Control path that indicates that the HS could perform a local ring on the headphone that there is a incoming cal
26、l HS receives a Data path establishment indication (the Data path being initiated by the AG). A ring tone is communicated by the AG to the HS using a in-band signal on the Data path established earlier. User at HS presses a button to signal acceptance of the incoming call. This signal is sent to the
27、 AG. HS receives a confirmation from the AG for the call accept sent via the button press at HS. Voice data is received on the Data path and rendered on the headphone appropriately. 第 7 页 共 20 页 HANDESET Programmers Guide 洪林整理 4.1.4 Call transfer from AG to HS Here we present a case by which the HS
28、transfers a call from the AG to itself (when the call was being attended at the AG). This is accomplished as follows: User at HS presses a button to signal acceptance of the call. This causes the following things to happen. HS initiates a Control path establishment to the AG. After which the button
29、press is communicated to the AG. The AG responds to the button press indication with a positive response. HS then receives a Data path establishment indication (the Data path being initiated by the AG. Voice data is received on the Data path and rendered on the headphone appropriately. 第 8 页 共 20 页
30、HANDESET Programmers Guide 洪林整理 4.1.5 Call termination Given that the Control path and Data path have been established and voice data is streaming from the AG to the HS via the Data path; the HS can terminate the call as follows: User presses the button, this leads to the button press command being
31、sent from the HS to the AG Upon reception of positive confirmation, the HS waits for the AG to release the Data path release the Control path 第 9 页 共 20 页 HANDESET Programmers Guide 洪林整理 4.1.6 To notify AG about current volume levels The HS typically informs the AG of the volume levels of the speaker and microphone soon after the establishment of the Control path as follows: Issue the command intimating the AG of the current speaker volume level. Receive a confirmation for the same from the AG. 第 10 页 共 20 页 HANDESET Programmers Guide 洪林整理 4.1.7 Proprietary commands In cert
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1