?? headset_security.c
字號:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.6.2-release
FILE NAME
headset_security.c
DESCRIPTION
This file contains the Authentication functionality for the AV Headset
Application.
*/
/****************************************************************************
Header files
*/
#include "headset_private.h"
#include "av_stream_control.h"
#include "headset_common.h"
#include "headset_security.h"
#include "headset_tones.h"
#include "hfp_slc.h"
#include "leds.h"
#include <stdlib.h>
#include <stdio.h>
#include <ps.h>
#include <pio.h>
/**************************************************************************/
void headsetHandlePinCodeInd(const headsetTaskData *app, const CL_SM_PIN_CODE_IND_T *ind)
{
uint16 pin_length = 0;
uint8 pin[16];
uint8 pin_security;
if ((PsRetrieve(HEADSET_SECURITY, &pin_security, sizeof(uint8))) ==0)
pin_security = 1;
/* Only send our PIN if the headset is in pairing mode (and the security PS Key is set),
or we initiated a connection.
*/
if (isHeadsetPairing(app) || (pin_security == 0) || (app->headset_connecting_hfp) || (app->headset_connecting_av))
{
/* Do we have a fixed pin in PS, if not reject pairing (by setting the length to zero) */
if ((pin_length = PsFullRetrieve(PSKEY_FIXED_PIN, pin, 16)) == 0 || pin_length > 16)
pin_length = 0;
}
/* Respond to the PIN code request */
ConnectionSmPinCodeResponse(&ind->bd_addr, pin_length, pin);
}
/*****************************************************************************/
void headsetHandleAuthoriseInd(const CL_SM_AUTHORISE_IND_T *ind)
{
ConnectionSmAuthoriseResponse(&ind->bd_addr, ind->protocol_id, ind->channel, ind->incoming, 1);
}
/*****************************************************************************/
void headsetHandleAuthenticateCfm(const CL_SM_AUTHENTICATE_CFM_T *cfm)
{
bdaddr addr;
if (cfm->status == auth_status_success)
{
addr = cfm->bd_addr;
/* Pairing complete so send a pair mode end message immediately */
(void) MessageCancelAll(getAppTask(), APP_PAIR_MODE_END_IND);
MessageSend(getAppTask(), APP_PAIR_MODE_END_IND, 0);
(void)PsStore(LAST_PAIRED_DEVICE, &addr, sizeof(bdaddr));
}
}
/*****************************************************************************/
void headsetEnterPairingMode(headsetTaskData *app)
{
app->pairing_enabled = 1;
headsetPlayTone(app, tone_type_pairing);
/* Set the pairing timeout */
MessageSendLater(getAppTask(), APP_PAIR_MODE_END_IND, 0, PAIRING_TIMEOUT);
/*indicate pairing mode*/
ledsPlay( RED_BLUE_ALT_RPT_FAST ) ;
}
/*****************************************************************************/
void headsetExitPairingMode(headsetTaskData *app)
{
/* No longer in pairing mode */
app->pairing_enabled = 0;
if (isHeadsetIdle(app))
ledsPlay( BLUE_SHORT_ON_RPT ) ;
}
/*****************************************************************************/
void headsetClearPairedDevices(headsetTaskData *app)
{
ConnectionSmDeleteAllAuthDevices(HEADSET_MSG_BASE);
/*If the device is in pairing mode disable pairing*/
if (isHeadsetPairing(app))
MessageSend(getAppTask(), APP_PAIR_MODE_END_IND, 0);
/* Close down any active AV link */
if ((app->a2dp_state == avHeadsetA2dpConnected) || (app->a2dp_state == avHeadsetA2dpStreaming) || (app->a2dp_state == avHeadsetA2dpSignallingActive))
{
A2dpCloseAll(app->a2dp);
}
/* Close down any active AVRCP link */
if (app->avrcp_state == avHeadsetAvrcpConnected)
AvrcpDisconnect(app->avrcp);
/* Close down any active AG link */
if ((app->hfp_state != headsetInitialising) && (app->hfp_state != headsetReady))
hfpHeadsetDisconnectSlc(app);
/* Reset the last used AG */
(void )PsStore (LAST_USED_AG, 0, 0);
/* Reset the Last used AV source */
(void)PsStore (LAST_USED_AV_SOURCE ,0 ,0);
/* Reset the codec type of the Last used AV source */
(void)PsStore (LAST_USED_AV_SOURCE_SEP ,0 ,0);
/*Clear the last paired device*/
(void)PsStore (LAST_PAIRED_DEVICE ,0 ,0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -