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

📄 a2dp_sd_initiate.c

📁 蓝牙a2dp_source_dongle的例程
💻 C
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release

FILE NAME
    a2dp_sd_initiate.c

DESCRIPTION
    Initiate connection to remote device.

NOTES
    
*/


/****************************************************************************
    Header files
*/
#include "a2dp_sd_private.h"
#include "a2dp_sd_discover.h"
#include "a2dp_sd_initiate.h"

#include <bdaddr.h>
#include <message.h>
#include <panic.h>
#include <stdlib.h>


/****************************************************************************
NAME    
    a2dpSdInitiateRequest
    
DESCRIPTION
    Create and send an APP_INITIATE_REQ message.

RETURNS
    void
*/
void a2dpSdInitiateRequest(const bdaddr *addr)
{
	/* Send initiate message to attempt AV connection if the device is in the correct state. */
    APP_INITIATE_REQ_T *message = PanicNull(malloc(sizeof(APP_INITIATE_REQ_T)));
    message->addr = *addr;
    MessageSend(getTheAppTask(), APP_INITIATE_REQ, message);

	/* Set the connect attempt timeout. */
	MessageSendLater(getTheAppTask(), APP_CONNECT_TIMEOUT_IND, 0, CONNECT_TIMEOUT);

	/* Reset the connect_timoeut_expired flag */
	resetConnectTimeoutFlag();
}


/****************************************************************************
NAME    
    a2dpSdKickProfileRequest
    
DESCRIPTION
    Request to kick the profile into action. This is triggered either as
    a result of a user initiated action or because we have USB data
    to stream.

RETURNS
    void
*/
void a2dpSdKickProfileRequest(a2dpSourceDongleTaskData *theApp)
{
    if (!BdaddrIsZero(&theApp->av_sink_addr))
	{
        /* We have a valid sink address to attempt to connect to it. */
        a2dpSdInitiateRequest(&(theApp->av_sink_addr));
	}
    else
        /* We don't have a valid sink address so try to discover one. */
        MessageSend(&theApp->task, APP_DISCOVER_REQ, 0);
}


/****************************************************************************
NAME    
    a2dpSdInitiateConnectionRequest
    
DESCRIPTION
    Initiate an AV connection to the remote device we have the address of.

RETURNS
    void
*/
void a2dpSdInitiateConnectionRequest(const a2dpSourceDongleTaskData *theApp, const APP_INITIATE_REQ_T *req)
{
    /* Update the local state */
    avSourceDongleUpdateA2dpState(a2dp_state_initiating);

    /* Disable security on outgoing connections to this device */
    ConnectionSmRegisterOutgoingService(&req->addr, protocol_l2cap, AVDTP_PSM, secl_none);

    /* Issue an open request */
    A2dpOpen(theApp->a2dp, a2dp_sbc, &req->addr);
}

⌨️ 快捷键说明

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