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

📄 win32.c

📁 在VC6.0上编译通过的蓝牙通信演示程序, COM1口控制.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************************
Copyright (C) Excelpoint System (Pte) Ltd. 2006

FILE: Win32.c

DESCRIPTION: This file contains event handler
*******************************************************************************/

#include <stdio.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <crtdbg.h> 
#include <time.h>
#include "demoBlueCAP.h"
#include "HBCP.h"

static BOOL isInStream = False;

static char filename[80];

/*-------------------------------------------------
Function:	HBCP_Pair_Status
Params: 	
	0 - succeeded
	1 - timed out
	2 - cancelled
	3 - failed
Description: Return the paring status in response to the request from host to enter or exit paring mode. 
Return: 	none
*/
void HBCP_Pair_Status(unsigned char ucStatus)
{
	switch (ucStatus)
	{
		case HBCP_STATUS_PAIR_SUCCESS:
			PRINT(" 				pairing successful.\n\n");
			break;
		case HBCP_STATUS_PAIR_TIMEOUT:
			PRINT(" 				pairing timeout.\n\n");
			break;
		case HBCP_STATUS_PAIR_CANCELLED:
			PRINT(" 				pairing cancelled.\n\n");
			break;
		case HBCP_STATUS_PAIR_FAILED:
			PRINT(" 				pairing failed.\n\n");
			break;
		case HBCP_STATUS_PAIRING_IN_PROGRESS:
			PRINT(" 				pairing in progress.\n\n");
			break;
		default:
			break;
	}
}
/*-------------------------------------------------
Function:	HBCP_HsHf_Ind
Params: 	
	1 - HS
	2 - HF
Description: This event informs host a RFCOMM link is established and which profile is used. 
Return: 	none
*/
void HBCP_HsHf_Ind(unsigned char ucStatus)
{
	switch (ucStatus)
	{
		case 1:
			PRINT(" 				Headset profile.\n\n");
			break;
		case 2:
			PRINT(" 				Handsfree profile.\n\n");
			break;
		default:
			break;
	}
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Ring_Ind
Params: 	none
Description: Inform host an incoming call. 
	This message is sent at a constant frequency until the call is handled.
Return: 	none
*/
void HBCP_Hshf_Ring_Ind(void)
{
	PRINT(" 				HSHF ring.\n\n");
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Set_Storage_Status
Parameters: 0 - failed
			1 - missed call
			2 - received call
			3 - dialed call
Description:Returns call list in response to host request. 
			This feature is supported only by Sony Ericsson and Motorola.
Return: 	none
*/
void HBCP_Hshf_Set_Storage_Status(unsigned char ucStatus)
{
	if(ucStatus==HBCP_STATUS_STORAGE_FAILED)
	{
		PRINT(" 				Set storage failed.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_STORAGE_MISSED_CALL)
	{
		PRINT(" 				List type: missed call.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_STORAGE_RECEIVED_CALL)
	{
		PRINT(" 				List type: received call.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_STORAGE_DIALED_CALL)
	{
		PRINT(" 				List type: dialed call.\n\n");
	}
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Volume_Level
Params: 	pParam[0] -- volume type: 0=hfp, 1=av
			pParam[1] -- volume level
Description:Display volume type and volume level 
Return: 	none
*/
void HBCP_Hshf_Volume_Level(unsigned char *pParam)
{
	char sLevel[3];
	
	if(pParam[0]==HBCP_STATUS_HFP_VOLUME)
		PRINT(" 				HSHF Volume level: ");
	else if(pParam[0]==HBCP_STATUS_AV_VOLUME) 	
		PRINT(" 				AV Volume level: ");
	
	sprintf(sLevel, "%d\0", pParam[1]);	
	PRINT(sLevel);
	PRINT("\n\n");
}

/*-------------------------------------------------
Function:	Host_Call_Status
Params: 	
	0 - calling (not used)
	1 - call established
	2 - call hooked
	3 - call failed
Description: Display call status 
Return: 	none
*/
void HBCP_Hshf_Call_Status(unsigned char ucStatus)
{
	if(ucStatus==HBCP_STATUS_CALL_IN_PROGRESS)
	{
		PRINT(" 				Call establishing.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_CALL_ESTABLISHED)
	{
		PRINT(" 				Call established.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_CALL_OFFHOOK)
	{
		PRINT(" 				Call hooked.\n\n");
	}
	else if(ucStatus==HBCP_STATUS_CALL_FAILED)
	{
		PRINT(" 				Call failed.\n\n");
	}
}
/*-------------------------------------------------
Function:	HBCP_Hshf_Sco_Ind
Params: 	
	0 - SCO disconnected
	1 - SCO connected
Description: Display SCO status
Return: 	none
*/
void HBCP_Hshf_Sco_Ind(unsigned char ucStatus)
{
	if(ucStatus == 0)
	{
		PRINT(" 				HSHF SCO disconnected.\n\n");
	}
	else if(ucStatus == 1)
	{
		PRINT(" 				HSHF SCO connected.\n\n");
	}
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Call_Waiting
Parameters: Maximum length of caller name is 16.
Description:Notify host that another call is coming in while engaged with current call.
Return: 	none
*/
void HBCP_Hshf_Call_Waiting(unsigned char ucLen, unsigned char *pNum)
{
	char temp[17];

	PRINT(" 				HSHF Call waiting: ");
	if (ucLen>16)
		ucLen = 16;
	memcpy(temp, pNum, ucLen);
	temp[ucLen]='\0';
	/* Display in the middle of the screen. */
	PRINT(temp);
	PRINT("\n\n");
}

/*-------------------------------------------------
Function:	 HBCP_Paired_Dev_Name
Params: 	 Storage entry number and paired device name
Description: Display the paired device name
Return: 	 none
*/
void HBCP_Paired_Dev_Name(unsigned char ucLen, unsigned char * pParam)
{
	char buffer[3];
	
	pParam[ucLen] = 0;
	PRINT(" 				Storage entry: ");
	PRINT(itoa(pParam[0], buffer, 10));
	PRINT("\n");
	PRINT(" 				Paired Dev name: ");
	PRINT(pParam+1);
		
	PRINT("\n\n");
	memset(pParam, 0, ucLen);	
}

/*---------------------------------------------------*/
/*sxg 20070108*/
void HBCP_Get_Pin(unsigned char ucLen, unsigned char * pParam)
{	
	pParam[ucLen] = 0;
	PRINT("\n\n");
	PRINT(" 			Read	Pin: ");	
	PRINT(pParam);
		
	PRINT("\n\n");
	memset(pParam, 0, ucLen);	
}

/*---------------------------------------------------*/
/*sxg 20070105*/
void HBCP_Iinitialized_Complete()
{
		PRINT(" 				Self Initialisation Completed.\n\n");
}

/*-------------------------------------------------
Function:	 HBCP_Connected_Dev_Name
Params: 	 Storage entry number and paired device name
Description: Display the paired device name
Return: 	 none
*/
void HBCP_Connected_Dev_Name(unsigned char ucLen, unsigned char * pParam)
{
	char buffer[3];
	pParam[ucLen] = 0;
	PRINT(" 				Storage entry: ");
	PRINT(itoa(pParam[0], buffer, 10));
	PRINT("\n");
	PRINT(" 				Connected Dev name: ");
	PRINT(pParam+1);
		
	PRINT("\n\n");
	memset(pParam, 0, ucLen);	
}

/*-------------------------------------------------
Function:	 HBCP_Hshf_Inquiry_Result
Params: 	 Storage entry number and paired device name
Description: Display the paired device name
Return: 	 none
*/
void HBCP_Hshf_Inquiry_Result(unsigned char * pParam)
{
	char buffer[3]={0};
	int i = 0;
			
	
	if(pParam[0] == 0)
	{
		PRINT(" 				Inquiry comepleted. ");
		PRINT("\n\n");
		memset(pParam, 0, *(pParam-1));	
		return;
	}
	PRINT("	Inquiry result: ");	
	PRINT(itoa(pParam[1], buffer, 10));
	PRINT("\n");
	
	PRINT("	Bluetooth Address: ");
	for(i =2 ; i< 8; i++)
	{
		printf("%x", pParam[i]);
		if(i<7)
				printf("-");
	}
		
	PRINT("\n\n");
	memset(pParam, 0, *(pParam-1));	
}


/*-------------------------------------------------
Function:	 HBCP_No_Paired_Dev
Parameters:  none
Description: Notify host that there is no paired device.
Return: 	 none
*/
void HBCP_No_Paired_Dev(void)
{
	PRINT(" 				No Paired dev!");		
	PRINT("\n\n");	
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Caller_Id
Parameters: Maximum length of caller ID is 16.
Description:When a call incoming, BlueCore passes the caller ID to host if relevant 
			GSM subscriber service is available.
Return: 	none
*/
void HBCP_Hshf_Caller_Id(unsigned char ucLen, unsigned char *pNum)
{
	char temp[17];

	PRINT(" 				HSHF Caller ID: ");
	if (ucLen>16)
		ucLen = 16;
	memcpy(temp, pNum, ucLen);
	temp[ucLen]='\0';
	/* Display in the middle of the screen. */
	PRINT(temp);
	PRINT("\n\n");
}

/*-------------------------------------------------
Function:	HBCP_Hshf_Caller_Name
Parameters: Maximum length of caller name is 16.
Description:When a call incoming, BlueCore passes the caller name (if any) to host 
			if relevant GSM subscriber service is available.
Return: 	none
*/
void HBCP_Hshf_Caller_Name(unsigned char ucLen, unsigned char *pName)
{
	char temp[17];

	PRINT(" 				HSHF Caller Name: ");
	if (ucLen>16)
		ucLen = 16;
	memcpy(temp, pName, ucLen);
	temp[ucLen]='\0';
	/* Display in the middle of the screen. */
	PRINT(temp);
	PRINT("\n\n");

}

/*-------------------------------------------------
Function:	HBCP_BLUECORE_On_Off
Params: 	
	0 - SCO disconnected
	1 - SCO connected
Description: Display SCO status
Return: 	none
*/
void HBCP_BLUECORE_On_Off(unsigned char ucStatus)
{
	if(ucStatus == 0)
	{
		PRINT(" 				BLUECORE Power Off.\n\n");
	}
	else if(ucStatus == 1)
	{
		PRINT(" 				BLUECORE Power On.\n\n");
	}
}

/*-------------------------------------------------
Function:	HBCP_AV_Status
Parameter:	0 - AV initialising
			1 - AV ready (to be connected)
			2 - AV initiating
			3 - AV connected
			4 - AV streaming
Description:Notify host av status. 
			Host side can switch audio channel accordingly by the status change. 
Return: 	none
*/
void HBCP_AV_Status(unsigned char ucStatus)
{
	switch (ucStatus)
	{
		case HBCP_STATUS_AV_INITIALISING:
			PRINT(" 				AV initialising.\n\n");
			break;
		case HBCP_STATUS_AV_READY:
			PRINT(" 				AV ready.\n\n");
			break;
		case HBCP_STATUS_AV_INITIATING:
			PRINT(" 				AV initiating.\n\n");
			break;
		case HBCP_STATUS_AV_CONNECTED:
			PRINT(" 				AV connected.\n\n");
			break;
		case HBCP_STATUS_AV_STREAMING:
			PRINT(" 				AV streaming.\n\n");
			break;
		default:
			break;
	}
}

/*-------------------------------------------------
Function:	HBCP_AV_Status
Parameter:	0 - AV initialising
			1 - AV ready (to be connected)
			2 - AV initiating
			3 - AV connected
			4 - AV streaming
Description:Notify host av status. 
			Host side can switch audio channel accordingly by the status change. 
Return: 	none
*/
void HBCP_Hshf_Status(unsigned char ucStatus)
{
	switch (ucStatus)
	{
		case HBCP_STATUS_AV_INITIALISING:
			PRINT(" 				AV initialising.\n\n");
			break;
		case HBCP_STATUS_AV_READY:
			PRINT(" 				AV ready.\n\n");
			break;
		case HBCP_STATUS_AV_INITIATING:
			PRINT(" 				AV initiating.\n\n");
			break;
		case HBCP_STATUS_AV_CONNECTED:
			PRINT(" 				AV connected.\n\n");
			break;
		case HBCP_STATUS_AV_STREAMING:
			PRINT(" 				AV streaming.\n\n");
			break;
		default:
			break;
	}
}


/*-------------------------------------------------
Function:	HBCP_Hshf_All_Status
Parameter:	0 - AV initialising
			1 - AV ready (to be connected)
			2 - AV initiating
			3 - AV connected
			4 - AV streaming
Description:Notify host av status. 
			Host side can switch audio channel accordingly by the status change. 
Return: 	none
*/
void HBCP_Hshf_All_Status(unsigned char *ucStatus)
{
	
		if((ucStatus[0] & 0xf0)== 0)
			PRINT(" 				CALL Status - initialising.\n\n");
			
		else if((ucStatus[0] & 0xf0)== 0x10)
			PRINT(" 				CALL Status - Ready.\n\n");
			
		else if((ucStatus[0] & 0xf0)== 0x20)
			PRINT(" 				CALL Status - Connecting.\n\n");
			
		else if((ucStatus[0] & 0xf0)== 0x30)
			PRINT(" 				CALL Status - Connected.\n\n");
			
		else if((ucStatus[0] & 0xf0)== 0x40)
			PRINT(" 				CALL Status - IncomingCall.\n\n");
			
		else if((ucStatus[0] & 0xf0)== 0x70)
			PRINT(" 				CALL Status - OutgoingCall.\n\n");

		else if((ucStatus[0] & 0xf0)== 0x80)
			PRINT(" 				CALL Status - ActiveCall.\n\n");
		
		else	
			PRINT(" 				CALL Status - Wrong.\n\n");
			
		/*for AV*/	
		if((ucStatus[0] & 0x0f)== 0)
			PRINT(" 				AV Status - initialising.\n\n");
			
		else if((ucStatus[0] & 0x0f)== 0x01)
			PRINT(" 				AV Status - Ready.\n\n");
		
		else if((ucStatus[0] & 0x0f)== 0x02)
			PRINT(" 				AV Status - Initiating.\n\n");
			
		else if((ucStatus[0] & 0x0f)== 0x04)
			PRINT(" 				AV Status - Connected.\n\n");
			

⌨️ 快捷键说明

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