蓝牙耳机编程流程HANDESET Programmers Guide.docx
《蓝牙耳机编程流程HANDESET Programmers Guide.docx》由会员分享,可在线阅读,更多相关《蓝牙耳机编程流程HANDESET Programmers Guide.docx(21页珍藏版)》请在冰豆网上搜索。
![蓝牙耳机编程流程HANDESET Programmers Guide.docx](https://file1.bdocx.com/fileroot1/2023-1/5/e28ce024-6ee5-4c40-a847-af5f5ef10625/e28ce024-6ee5-4c40-a847-af5f5ef106251.gif)
蓝牙耳机编程流程HANDESETProgrammersGuide
蓝牙耳机编程流程-HANDESETProgrammersGuide
HANDESETProgrammersGuide洪林整理
HANDESETProgrammersGuide
1.Introduction
HeadsetprofileisusedtoenablewirelessconnectivityamongBluetoothenabledHeadsets,PCsandthecellularphones.
2.Concepts
2.1USAGE(用法)
TwousecasesarepresentedhereforunderstandingtheAGandHSroles.Notethatthesecasesarenotcomprehensive.
Incomingcall
1Incomingcallarrivesatacellularphoneconnectedtoamobilenetwork.
2ThecellularphoneactingasanAGindicatesthiscallarrivaltoaHeadset.ThisistypicallyperceivedasaringontheHS.
3Theuseracceptstheincomingcall,bypressingabuttonontheHS.
第1页共20页
HANDESETProgrammersGuide洪林整理
4TheAGonreceivingthisacceptanceroutestheaudiodatafromthenetworktoHS.Outgoingcall
1Anuserdialsanumberusingacellularphone(AG).
2Uponsuccessfulconnection,theuserbypressingabuttonontheHSinitiatesatransferoftheaudiodatafromthecellphonetotheHS.
Note:
1Headset'stypicallyhaveauserinterfacebywhichintentionssuchascallaccept,calltransferareindicatedtotheAG.
2Thewordbuttonusedaboveisasimileforanysuchuserinterface
3IMPORTANT:
Althoughthewordcallisfrequentlyusedinthisdocument,itshallbereadas'Audioconnection'.ThisisbecausetheAGmaytreattheHSastheinputoroutputaudioportforpurposesotherthancallprocessing(suchastunes,beeps,alarms,etc..).
2.2控制路径和数据路径
1,AControlpathtypicallytransmitscommandsandresponsesrelatingtoaprofileandtheDatapathistypicallyusedtotransmitvoicedata
2AControlpathshouldbeestablishedpriortotheestablishmentoftheDatapath.
3TheexistenceofaDatapathisoptional
4.InthecontextoftheHeadsetprofilecommandsandresponsesrelatingtocallacceptance,audiodatatransfer,volumecontroletc..areexchangedbetweentheAGandHSovertheControlpathandtheDatapathisusedtotransferaudio(voice)databetweentheAGandtheHS
2.3MODULE
Theprofileimplementationconsistsofthreemodules.Theseareoutlinedbelow.
ThisprovidestheserialportinterfacethatbothHSandAGusetoSPChannelestablish/releaseControlandDatapaths.(SeeSPChannel
programmersguidefordetails).
ImplementationoftheHSportionoftheprofile;usedbyapplicationsHeadset(HS)residingontheHS.
ImplementationoftheAGportionoftheprofile;usedbyapplicationsAudio-Gateway(AG)residingontheAG.
第2页共20页
HANDESETProgrammersGuide洪林整理
2.4Applicationstate
TheHeadsetAPIisstatelessinnature.Thismeansthattheapplicationhastokeeptrackofstates.
Thepossiblestatesofanapplication(withrespecttotheHeadsetprofile)aretypically
StateDescription
NOTHeretheControlpathisnotestablished.CONNECTED
HeretheControlpathisestablishedbuttheDatapathCONNECTEDisnot.
TheDatapathisalsoestablishedhereandisbeingusedIN_CALLtostreamvoicetheAGtotheHS.
2.5EstablishmentandreleaseofControlandDatapaths
ThefollowingmatrixspecifiesthecorrelationbetweentheControl/DatapathsandtherolesaspertheHeadsetprofilespecification.
ActionEstablishRelease
ControlHSorAGAGPathDataAGAG
第3页共20页
HANDESETProgrammersGuide洪林整理
i.e.
1TheControlpathcanbeestablishedeitherbytheHSorAGwhileitsreleasecanbeperformedonlybytheAG.
2TheDatapathcanbeestablishedandreleasedonlybytheAG
2.6SPChannelAPI
TheSPChannelAPIthatprovidesameanstoestablishandreleaseControlandDatapathsisusedbytheHeadsetAPI.ThereaderisrecommendedtoreadtheSPChannelprogrammersguidebeforeproceedingfurther.
2.7HeadsetAPIusage
FromtheHSend
HSinitialization
Toacceptanincomingcall.
TotransferthecallfromtheAGtotheHS.
Toterminatethecall.
TonotifyAGaboutspeakerandmicrophonevolumelevels.
Proprietarycommands
HSun-initialization
NotethattheHSinitializationandun-initializationarenotnecessarilyrequirementsbuthavebeenincludedhereforthesakeofcompletenessoftheAPIusage.
FromtheAGend
AGinitialization
TonotifytheHSofanincomingcall.
TotransferthecallfromtheHStotheAG.
TocontrolthespeakerandmicrophonevolumelevelsoftheHS.
Proprietaryunsolicitedresultcodes
AGun-initialization
2.8Buttonpresshandling
TheHeadsetspecificationusestheword'Userinitiatedaction'tomeananindicationreceivedfromtheuser(typicallyabuttonpress,oraGUIclicketc..)toperformasuitableaction.The
第4页共20页
HANDESETProgrammersGuide洪林整理
suitableactioninthecontextHSintheHeadsetspecificationiseitheracallaccept,calltransferorcallterminate.Thusthesame'Userinitiatedaction'thatisconveyedbytheHStotheAGisinterpreteddifferently.ThisisbasedonthestatesoftheHSandAGapplicationsthatarecurrentlyinteractionwitheachother.
TheHS_SendButtonPressfunctionoftheHSAPIisusedtomodelthis'Useinitiatedaction'.Weshallnowlookatwhatitmeanstohandlethebuttonpressatthe
Headsetendand
Gatewayend
3.Requirements
TherequirementsontheHSandAGunitsofthisprofilearestatedinthetablebelow.
RequirementDescription
AbilitytoestablishaconnectioninordertotreattheIncomingaudioconnectionHSasanoutputaudioportoftheAG.
AbilitytoestablishaconnectioninordertotreattheOutgoingaudioconnectionHSasaninputaudioportoftheAG.
AudioconnectiontransferTransferringtheaudiobetweentheHSandAG.
RemoteaudiovolumecontrolAbilityoftheAGtoadjustthevolumelevelontheHS.
4.APIUsage
Thissectionpresentstheusageofheadset(HSandAG)APIfunction.ExampleusecasescenariosarepresentedheretohighlightAPIusage.
4.1UsageofHSAPI
TheusageoftheHSAPIispresentedinthefollowingsections.
第5页共20页
HANDESETProgrammersGuide洪林整理4.1.1HSinitializationTheHSapplicationmustfirstinitializetheHSprofile.Thisisdoneasfollows:
EstablishaSPChannelControlpath
Usetheactive(established)SPChannelhandletocreate(initialize)theHS_Handle.
ThisHF_HandlewillbeusedinalltheothercallsoftheHSAPI.
Notethatwhethertheapplicationislisteningorconnecting,successfulestablishmentofa
Controlpathwillbeindicatedusingthespchannel_open_cfmcallback.
4.1.2Toacceptanincomingcall(I)
HerewepresentthecaseonhowtheHSacceptsanincomingcall.
Thisisaccomplishedasfollows:
HSwaitsforanincomingControlpathestablishmentbytheAG.
HSreceivestheRINGcodeontheControlpaththat
indicatesthattheHScouldperformalocalringontheheadphone
thatthereisaincomingcall
UseratHSpressesabuttontosignalcallacceptanceoftheincomingcall.Thissignalissent
totheAG.
HSreceivesaconfirmation(response)fromtheAGforthecallaccept.
HSreceivesaDatapathestablishmentindication(theDatapathbeinginitiatedbytheAG).
VoicedataisreceivedontheDatapathandrenderedontheheadphoneappropriately.
第6页共20页
HANDESETProgrammersGuide洪林整理
4.1.3Toacceptanincomingcall(II)
HerewepresentanothercasebywhichtheHSacceptsanincomingcall.
Thisisaccomplishedasfollows:
HSwaitsforanincomingControlpathestablishmentbytheAG.
HSreceivestheRINGcodeontheControlpaththat
indicatesthattheHScouldperformalocalringontheheadphone
thatthereisaincomingcall
HSreceivesaDatapathestablishmentindication(theDatapathbeinginitiatedbytheAG).
AringtoneiscommunicatedbytheAGtotheHSusingain-bandsignalontheDatapath
establishedearlier.
UseratHSpressesabuttontosignalacceptanceoftheincomingcall.Thissignalissentto
theAG.
HSreceivesaconfirmationfromtheAGforthecallacceptsentviathebuttonpressatHS.
VoicedataisreceivedontheDatapathandrenderedontheheadphoneappropriately.
第7页共20页
HANDESETProgrammersGuide洪林整理
4.1.4CalltransferfromAGtoHSHerewepresentacasebywhichtheHStransfersacallfromtheAGtoitself(whenthecall
wasbeingattendedattheAG).Thisisaccomplishedasfollows:
UseratHSpressesabuttontosignalacceptanceofthecall.Thiscausesthefollowing
thingstohappen.
HSinitiatesaControlpathestablishmenttotheAG.
AfterwhichthebuttonpressiscommunicatedtotheAG.
TheAGrespondstothebuttonpressindicationwithapositiveresponse.
HSthenreceivesaDatapathestablishmentindication(theDatapathbeinginitiatedbythe
AG.
VoicedataisreceivedontheDatapathandrenderedontheheadphoneappropriately.
第8页共20页
HANDESETProgrammersGuide洪林整理
4.1.5Calltermination
GiventhattheControlpathandDatapathhavebeenestablishedandvoicedataisstreamingfromtheAGtotheHSviatheDatapath;theHScanterminatethecallasfollows:
Userpressesthebutton,thisleadstothebuttonpresscommandbeingsentfromtheHSto
theAG
Uponreceptionofpositiveconfirmation,theHSwaitsfortheAGto
releasetheDatapath
releasetheControlpath
第9页共20页
HANDESETProgrammersGuide洪林整理
4.1.6TonotifyAGaboutcurrentvolumelevels
TheHStypicallyinformstheAGofthevolumelevelsofthespeakerandmicrophonesoonaftertheestablishmentoftheControlpathasfollows:
IssuethecommandintimatingtheAGofthecurrentspeakervolumelevel.
ReceiveaconfirmationforthesamefromtheAG.
第10页共20页
HANDESETProgrammersGuide洪林整理
4.1.7Proprietarycommands
Incert