⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a2dp_sd_avrcp.c

📁 CSR蓝牙MP3播放USB DONGLE源码
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release

FILE NAME
    a2dp_sd_avrcp.c

DESCRIPTION
    RCP support functions

NOTES
    
*/


/****************************************************************************
    Header files
*/
#include "a2dp_sd_private.h"
#include "a2dp_sd_avrcp.h"
#include "a2dp_sd_interface.h"

#include <avrcp.h>
#include <string.h>


/* Send response to the AVRCP lib */
static void sendRcpConnectResponse(AVRCP *avrcp, const AVRCP_CONNECT_IND_T *ind, bool accept)
{
    /* Send the connect response */
    AvrcpConnectResponse(avrcp, ind->connection_id, accept);
}


/****************************************************************************
NAME
    a2dpSdRcpHandleConnectInd   
    
DESCRIPTION
    Handle a request to establish an incoming RCP connection. 

RETURNS
    void
*/
void a2dpSdRcpHandleConnectInd(AVRCP *avrcp, const bdaddr *addr, const AVRCP_CONNECT_IND_T *ind)
{
    /* Make sure we only accept an RCP connection from a device we're already connected to */
    if (addr->nap == ind->bd_addr.nap &&
        addr->uap == ind->bd_addr.uap &&
        addr->lap == ind->bd_addr.lap)
        sendRcpConnectResponse(avrcp, ind, 1);
    else
        sendRcpConnectResponse(avrcp, ind, 0);
}


/****************************************************************************
NAME    
    a2dpSdRcpHandleConnectIndReject

DESCRIPTION
    Reject the RCP connection we're in the wrong state.

RETURNS
    void
*/
void a2dpSdRcpHandleConnectIndReject(AVRCP *avrcp, const AVRCP_CONNECT_IND_T *ind)
{
    /* Reject the RCP connection */
    sendRcpConnectResponse(avrcp, ind, 0);
}


/****************************************************************************
NAME    
    a2dpSdRcpHandleConnectCfm

DESCRIPTION
    Handle a connect_cfm message indicating whether the RCP connection
    was successfully established.

RETURNS
    void
*/
void a2dpSdRcpHandleConnectCfm(a2dpSourceDongleTaskData *theApp, const AVRCP_CONNECT_CFM_T *cfm)
{
    /* If connection successful update the local state */
    if (cfm->status == avrcp_success)
    {
        /* Update the local state */
        avSourceDongleUpdateAvrcpState(avrcp_state_connected);

        /* Store the RCP sink */
        theApp->rcp_sink = cfm->sink;
    }
    else
        theApp->rcp_sink = 0;
}


/****************************************************************************
NAME    
    a2dpSdRcpHandleDisconnect

DESCRIPTION
    The RCP connection has been disconnected by either the local or the 
    remote end.

RETURNS
    void
*/
void a2dpSdRcpHandleDisconnect(a2dpSourceDongleTaskData *theApp)
{
    /* Update the local state to accepting */
    avSourceDongleUpdateAvrcpState(avrcp_state_accepting);

    /* Reset the RCP sink */
    theApp->rcp_sink = 0;
}


/****************************************************************************
NAME    
    a2dpSdRcpHandlePassthroughInd

DESCRIPTION
    Sent by the library when the remote control has issued a passthrough 
    command. Send back the response and action the comand.

RETURNS
    void
*/
void a2dpSdRcpHandlePassthroughInd(AVRCP *avrcp, const AVRCP_PASSTHROUGH_IND_T *ind)
{
    /* Acknowledge the request */
    AvrcpPassthroughResponse(avrcp, avctp_response_accepted);

	a2dpSdHandleButtons(ind->opid, ind->state);
}


/****************************************************************************
NAME    
    a2dpSdRcpHandleUnitInfoInd

DESCRIPTION
    The remote device has issued the UnitInfo command.

RETURNS
    void
*/
void a2dpSdRcpHandleUnitInfoInd(AVRCP *avrcp, const AVRCP_UNITINFO_IND_T *ind)
{
    /* Send a UnitInfo response. We don't have a company ID, so we return all f's */
    AvrcpUnitInfoResponse(avrcp, 1, subunit_panel, 0, 0xffffff);
}


/****************************************************************************
NAME    
    a2dpSdRcpHandleSubUnitInfoInd

DESCRIPTION
    The remote device has issued the SubunitInfo command.

RETURNS
    void
*/
/*lint -e641 */
void a2dpSdRcpHandleSubUnitInfoInd(AVRCP *avrcp, const AVRCP_SUBUNITINFO_IND_T *ind)
{
    bool accept = 0;
    uint8 page_data[PAGE_DATA_LENGTH];
    memset(page_data, 0, PAGE_DATA_LENGTH);

    /* We only have content for page zero. */
    if (!ind->page)
    {
        /* Fill in the single subunit with address 0 and pad with 0xff's */
        page_data[0] = subunit_panel<<3;
        page_data[1] = 0xff;
        page_data[2] = 0xff;
        page_data[3] = 0xff;
    }
    
    /* Send response back to the lib */
    AvrcpSubUnitInfoResponse(avrcp, accept, page_data);
}
/*lint +e641 */

/****************************************************************************
NAME    
    a2dpSdRcpHandleVendorDependentInd

DESCRIPTION
    The remote device has issued a VendorDependent command.

RETURNS
    void
*/
void a2dpSdRcpHandleVendorDependentInd(AVRCP *avrcp, const AVRCP_VENDORDEPENDENT_IND_T *ind)
{
    /*
        We are not a target so reject vendor requests
    */
	AvrcpVendorDependentResponse(avrcp, avctp_response_not_implemented);
}

⌨️ 快捷键说明

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