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

📄 ag_open.c

📁 bluetooth audio gateway
💻 C
字号:
#include "ag_private.h"
#include "ag.h"
#include "ag_types.h"

#include <event.h>
#include <message.h>


static void registerService(ag_profile_role_t profile)
{
	MAKE_MSG(CM_SERVICE_REGISTER_REQ);
	msg->serviceRecord = agCreateServiceRecord(&msg->sizeServiceRecord, profile);
	msg->classOfDevice = EAG_COD; /* the cod is the same for either profile */
	agPutCmMsg(msg);
}


/*
    AGstartReq

    Start request from the client app to kick off the whole thing. Currently
    only one type of extra data supported so this function only handles that.
*/
void startReqAction(uint16 hfSuppFeatures, ag_profile_role_t profiles)
{
    /* Init the supported profiles and current profile */
	agSetSupportedProfiles(profiles);
	agSetCurrentProfile(agProfileNotSet);
    
	/* Reset the server channels */
	AGState.agHsServerChan = 0;
	AGState.agHfServerChan = 0;

	/* Init the AG state */
    agSetCurrentState(AgIdle);
    AGState.ringContinuous = 0;

	/* Initialise the address to ag_handle map */
    createAddressHandleMap();

	/* The MSW defines the network type while the LSW defines the supported features */
	AGState.hfAgSupportedFeatures = hfSuppFeatures;

	/* Init the connection manager library */
    {
        MAKE_MSG(CM_INIT_REQ);    
        agPutCmMsg(msg);
    }

	/* enable the rfc data events */
    EventEnable(VM_EVENT_SOURCE, 1);
    EventEnable(VM_EVENT_SINK, 1);
}


/*
    agInitCfm

    Register Audio Gateway service with the Connection Manager.
*/
void agInitCfm(void)
{
	if (agIsHeadsetSupported())
		registerService(agHeadsetProfile);
	else if (agIsHandsFreeSupported())
		registerService(agHandsFreeProfile);
}


/*
    agServiceRegisterCfm

    Confirmation of service register request (can be success or
    failure).
*/
void agServiceRegisterCfm(const CM_SERVICE_REGISTER_CFM_T *cfm)
{
	/* TODO should check result code in cfm in case something failed */	

	/* Store the server channel */
	if (agIsHeadsetSupported() && !(AGState.agHsServerChan & 0xff))
        AGState.agHsServerChan = cfm->server_channel;
    else
        AGState.agHfServerChan = cfm->server_channel;
	 
	if (agIsHandsFreeSupported() && !(AGState.agHfServerChan & 0xff))
    {
        /* if both profiles are supported then register the second sdp record */
        registerService(agHandsFreeProfile);
    }
    else
	{
		/* If hands free supported default to that otherwise fall back to headset */
		if (agIsHandsFreeSupported())
			agSetCurrentProfile(agHandsFreeProfile);
		else
			agSetCurrentProfile(agHeadsetProfile);

		/* Initialization phase complete so let the driver know */
        handleStartCfm();
	}
}

⌨️ 快捷键说明

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