av_headset_auth.c

来自「csr 蓝牙芯片 无线蓝牙耳机的嵌入式程序」· C语言 代码 · 共 91 行

C
91
字号
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004

FILE NAME
    av_headset_auth.c        

DESCRIPTION
    This file contains the Authentication functionality for the AV Headset 
    Application

NOTES

*/


/****************************************************************************
    Header files
*/
#include "av_headset_private.h"
#include "av_headset_auth.h"

#include <ps.h>


/*************************************************************************
NAME    
     avHeadsetHandlePinCodeInd
    
DESCRIPTION
     This function is called on receipt on an CL_PIN_CODE_IND message
     being recieved.  The AV Headset default pin code is sent back.

RETURNS
     
*/
void avHeadsetHandlePinCodeInd(const avTaskData *theAvApp, const CL_SM_PIN_CODE_IND_T *ind)
{
    if (theAvApp->pairing_enabled)
    {
        uint16 pin_length = 0;
        uint8 pin[16];

        /* Do we have a fixed pin in PS, if not reject pairing */
         if ((pin_length = PsFullRetrieve(PSKEY_FIXED_PIN, pin, 16)) == 0 || pin_length > 16)
            /* Set length to 0 indicating we're rejecting the PIN request */
            pin_length = 0; 

        /* Respond to the PIN code request */
        ConnectionSmPinCodeResponse(&ind->bd_addr, pin_length, pin); 
    }
    else
        ConnectionSmPinCodeResponse(&ind->bd_addr, 0, (uint8*) "");
}


/****************************************************************************
NAME    
    avHeadsetHandleAuthoriseInd
    
DESCRIPTION
    Request to authorise access to a particular service.

RETURNS
    void
*/
void avHeadsetHandleAuthoriseInd(const CL_SM_AUTHORISE_IND_T *ind)
{
    ConnectionSmAuthoriseResponse(&ind->bd_addr, ind->protocol_id, ind->channel, ind->incoming, 1);
}


/****************************************************************************
NAME    
    headsetHandleAuthenticateCfm
    
DESCRIPTION
    Indicates whether the authentication succeeded or not.

RETURNS
    void
*/
void avHeadsetHandleAuthenticateCfm(const CL_SM_AUTHENTICATE_CFM_T *cfm)
{
    if (cfm->status == auth_status_success)
    {
        /* Pairing complete so send a pair mode end message immediately */
        (void) MessageCancelAll(getAppTask(), PAIR_MODE_END);
        MessageSend(getAppTask(), PAIR_MODE_END, 0);
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?