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

📄 handle_connection.c

📁 pbap_client:bluetooth 可查询带有PBAP功能手机的Phonebook
💻 C
字号:
/****************************************************************************

DESCRIPTION
	Implementation for handling connection library messages and functionality
	
FILE
	handle_connection.c
	
*/

/****************************************************************************
    Header files
*/

#include <connection.h>
#include <print.h>
#include <ps.h>

#include "main.h"
#include "handle_connection.h"
#include "handle_pbap.h"


/* Message Handler Prototypes */
static void handleClInitCfm(applicationTaskData *pTask, CL_INIT_CFM_T *pMsg);
static void handleClPinCodeInd(applicationTaskData *pTask, CL_SM_PIN_CODE_IND_T *pMsg);

void handleConnectionMessages(applicationTaskData *pTask, MessageId pId, Message pMessage)
{
	switch (pId)
	{
	case CL_INIT_CFM:
		handleClInitCfm(pTask, (CL_INIT_CFM_T *)pMessage);
		break;
	case CL_SM_PIN_CODE_IND:
		handleClPinCodeInd(pTask, (CL_SM_PIN_CODE_IND_T *)pMessage);
		break;

	/* Ignored messages */
	case CL_DM_ACL_OPENED_IND:
		PRINT(("CL_DM_ACL_OPENED_IND [Ignored]\n"));
		break;
	case CL_DM_ACL_CLOSED_IND:
		PRINT(("CL_DM_ACL_CLOSED_IND [Ignored]\n"));
		break;
		
	default:
		PRINT(("Unhandled Connection Message\n"));
		break;
	}
}


/* Message Handlers */

static void handleClInitCfm(applicationTaskData *pTask, CL_INIT_CFM_T *pMsg)
{
	PRINT(("CL_INIT_CFM\n"));
	
	if (pTask->appState == AppStateUninitialised)
	{
		if (pMsg->status == success)
		{
			setState(&pTask->appState, AppStateConInited);

			initPbap(pTask);		
		}
		else
		{
			PRINT(("    UNABLE TO INITIALISE THE CONNECTION LIBRARY\n"));
		}
		
	}
	else
	{
		PRINT(("    CONNECTION LIBRARY ALREADY INITIALISED\n"));
	}
		
}

static void handleClPinCodeInd(applicationTaskData *pTask, CL_SM_PIN_CODE_IND_T *pMsg)
{
	uint8 lPincode[16];
	uint16 lLen;
	PRINT(("CL_SM_PIN_CODE_IND\n"));
	
	lLen = PsFullRetrieve(PSKEY_FIXED_PIN, lPincode, 16);
	
	ConnectionSmPinCodeResponse(&pMsg->bd_addr, lLen, lPincode); 
}

⌨️ 快捷键说明

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