📄 headset_init.c
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.6.2-release
FILE NAME
headset_init.c
DESCRIPTION
Tasks carried out during the initialisation of the headset.
*/
/****************************************************************************
Header files
*/
#include "headset_private.h"
#include "a2dp_handler.h"
#include "avrcp_handler.h"
#include "headset_init.h"
#include "headset_common.h"
#include <connection.h>
#include <hfp.h>
#include <panic.h>
#include <pio.h>
#include <ps.h>
#ifdef DEBUG_INIT
#define INIT_DEBUG(x) DEBUG(x)
#else
#define INIT_DEBUG(x)
#endif
/*****************************************************************************/
void hfpHeadsetHfpInit(void)
{
hfp_init_params init;
uint16 supp_features = (HFP_VOICE_RECOGNITION |
HFP_REMOTE_VOL_CONTROL);
/* Initialise an HFP profile instance */
#ifdef HFP_1_5
init.supported_profile = hfp_handsfree_15_profile;
#else
init.supported_profile = hfp_handsfree_profile;
#endif
init.supported_features = supp_features;
init.size_service_record = 0;
init.service_record = 0;
init.priority = 255;
HfpInit(getAppTask(), &init);
/* Initialise an HSP profile instance */
init.supported_profile = hfp_headset_profile;
init.supported_features = 0;
init.size_service_record = 0;
init.service_record = 0;
init.priority = 255;
HfpInit(getAppTask(), &init);
}
/*****************************************************************************/
void hfpHeadsetInitComplete(headsetTaskData *app, const HFP_INIT_CFM_T *cfm)
{
/* Make sure the profile instance initialisation succeeded. */
if (cfm->status == hfp_init_success)
{
/* Check for an hfp instance, that's registered first */
if (!app->hfp)
{
/* This must be the hfp instance */
app->hfp = cfm->hfp;
}
else
{
/* Its not HFP so must be HSP */
app->hsp = cfm->hfp;
/* Send an internal message to indicate init has completed */
MessageSend(getAppTask(), APP_HEADSET_INIT_CFM, 0);
}
}
else
/* If the profile initialisation has failed then things are bad so panic. */
Panic();
}
/**************************************************************************/
void avHeadsetHandleA2dpInitCfm(headsetTaskData* app, const A2DP_INIT_CFM_T* cfm)
{
uint8 mp3_enabled = 0;
if(cfm->status == a2dp_success)
{
/* A2DP Library initialisation was a success */
/* Keep a record of the A2DP instance */
if (!app->a2dp)
{
app->a2dp = cfm->a2dp;
/* Enable signalling channel indication for this application. */
A2dpEnableSignallingIndications(app->a2dp);
if (PsRetrieve(MP3_ENABLED, &mp3_enabled, sizeof(uint8)))
if (mp3_enabled)
{
/* Register Stream Endpoints - MP3 */
avHeadsetRegisterSep(app, a2dp_mpeg_audio);
INIT_DEBUG(("MP3 done\n"));
}
/* ... and SBC */
avHeadsetRegisterSep(app, a2dp_sbc);
}
}
else
{
INIT_DEBUG(("INIT: A2DP Init failed\n"));
}
}
/**************************************************************************/
void avHeadsetHandleAvrcpInitCfm(headsetTaskData* app, const AVRCP_INIT_CFM_T* cfm)
{
if(cfm->status == avrcp_success)
{
/* AVRCP Library initialisation was a success */
/* Keep a record of the AVRCP instance */
if (!app->avrcp)
{
app->avrcp = cfm->avrcp;
/* Initialise avrcp app variables */
app->avrcp_pending = FALSE;
/* Change to Ready state */
setAvrcpState(app, avHeadsetAvrcpReady);
/* Init the HFP lib */
hfpHeadsetHfpInit();
}
/* initialise the handler task */
app->controls_task.handler = controls_handler;
}
else
{
INIT_DEBUG(("INIT: AVRCP Init failed\n"));
}
}
/**************************************************************************/
void headsetInitReset(headsetTaskData *app)
{
/* Set the state to indicate the init has finished */
setHfpState(app, headsetReady);
/* Set the class of device to indicate this is a headset */
ConnectionWriteClassOfDevice(AUDIO_MAJOR_SERV_CLASS | AV_COD_RENDER | AV_MAJOR_DEVICE_CLASS | AV_MINOR_HEADSET);
/* Disable SDP security */
ConnectionSmSetSdpSecurityIn(TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -