蓝牙耳机编程流程HANDESET Programmers Guide文档格式.docx
《蓝牙耳机编程流程HANDESET Programmers Guide文档格式.docx》由会员分享,可在线阅读,更多相关《蓝牙耳机编程流程HANDESET Programmers Guide文档格式.docx(21页珍藏版)》请在冰豆网上搜索。
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页
2.4Applicationstate
TheHeadsetAPIisstatelessinnature.Thismeansthattheapplicationhastokeeptrackofstates.
Thepossiblestatesofanapplication(withrespecttotheHeadsetprofile)aretypically
StateDescription
NOTHeretheControlpathisnotestablished.CONNECTED
HeretheControlpathisestablishedbuttheDatapathCONNECTEDisnot.
TheDatapathisalsoestablishedhereandisbeingusedIN_CALLtostreamvoicetheAGtotheHS.
2.5EstablishmentandreleaseofControlandDatapaths
ThefollowingmatrixspecifiesthecorrelationbetweentheControl/DatapathsandtherolesaspertheHeadsetprofilespecification.
ActionEstablishRelease
ControlHSorAGAGPathDataAGAG
第3页共20页
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页
suitableactioninthecontextHSintheHeadsetspecificationiseitheracallaccept,calltransferorcallterminate.Thusthesame'
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页
4.1.3Toacceptanincomingcall(II)
HerewepresentanothercasebywhichtheHSacceptsanincomingcall.
AringtoneiscommunicatedbytheAGtotheHSusingain-bandsignalontheDatapath
establishedearlier.
UseratHSpressesabuttontosignalacceptanceoftheincomingcall.Thissignalissentto
theAG.
HSreceivesaconfirmationfromtheAGforthecallacceptsentviathebuttonpressatHS.
第7页共20页
4.1.4CalltransferfromAGtoHSHerewepresentacasebywhichtheHStransfersacallfromtheAGtoitself(whenthecall
wasbeingattendedattheAG).Thisisaccomplishedasfollows:
UseratHSpressesabuttontosignalacceptanceofthecall.Thiscausesthefollowing
thingstohappen.
HSinitiatesaControlpathestablishmenttotheAG.
AfterwhichthebuttonpressiscommunicatedtotheAG.
TheAGrespondstothebuttonpressindicationwithapositiveresponse.
HSthenreceivesaDatapathestablishmentindication(theDatapathbeinginitiatedbythe
AG.
第8页共20页
4.1.5Calltermination
GiventhattheControlpathandDatapathhavebeenestablishedandvoicedataisstreamingfromtheAGtotheHSviatheDatapath;
theHScanterminatethecallasfollows:
Userpressesthebutton,thisleadstothebuttonpresscommandbeingsentfromtheHSto
theAG
Uponreceptionofpositiveconfirmation,theHSwaitsfortheAGto
releasetheDatapath
releasetheControlpath
第9页共20页
4.1.6TonotifyAGaboutcurrentvolumelevels
TheHStypicallyinformstheAGofthevolumelevelsofthespeakerandmicrophonesoonaftertheestablishmentoftheControlpathasfollows:
IssuethecommandintimatingtheAGofthecurrentspeakervolumelevel.
ReceiveaconfirmationforthesamefromtheAG.
第10页共20页
4.1.7Proprietarycommands
Incert