Exemple #1
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
	This function is the entry function for HFP sample.
Arguments:
	void
Return:
	void 
---------------------------------------------------------------------------*/
void TestHfpFunc(void)
{
	BTUINT8 ch = 0;

	HfpShowMenu();	
	while (ch != 'r')
	{
		scanf(" %c", &ch);
		getchar();		
		if (ch == '\n')
		{
			printf(">>");
		}
		else if('r' == ch)
		{
			break;
		}
		else
		{
			HfpExecCmd(ch);
			printf("\n");
			HfpShowMenu();
		}
	}

	if (BTSDK_INVALID_HANDLE != s_currHFConnHdl)
	{
		Btsdk_Disconnect(s_currHFConnHdl);
		s_currHFConnHdl = BTSDK_INVALID_HANDLE;
	}
	HfpDone();
}
/**
* Disconnect
* Disconnect from the remote machine, by sending an
* OBEX disconnect, and closing the transport on (and
* regardless of) response from the server.
*/
void QBtObjectExchangeClientPrivate::Disconnect()
{
	if (connectionHandle != BTSDK_INVALID_HANDLE)
	{
		BTINT32 result = BTSDK_FALSE;
		result = Btsdk_Disconnect(connectionHandle);
		if(result != BTSDK_OK)
			emit p_ptr->error(QBtObjectExchangeClient::OBEXClientConnectionError);
		else
			emit p_ptr->disconnectedFromServer();
	}
}
Exemple #3
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
	This function is the execution function for HFP AG sample.
Arguments:
	choice: [in] choice you have selected.
Return:
	void 
---------------------------------------------------------------------------*/
void HfpAGExecCmd(BTUINT8 choice)
{
	BTBOOL bSCOExist = BTSDK_FALSE;	
	switch (choice)
	{	
	case '1': 
	       /* bSCOExist == TRUE indicates that initial HFP connection is in mute off state. 
		      bSCOExist == FALSE indicates that initial HFP connection is in mute on state. */
	       Btsdk_AGAP_IsAudioConnExisted(&bSCOExist);	
		   if (BTSDK_TRUE == bSCOExist)
		   {	
			   if (BTSDK_OK == Btsdk_AGAP_AudioConnTrans(s_currAGConnHdl))
			   {
				   printf("Mute on HFP connection successfully!\n");				   
			   }
			   else
			   {
				   printf("Cannot mute on HFP connection and an error occurs!\n");
			   }
		   }
		   else
		   {
			   if (BTSDK_OK == Btsdk_AGAP_AudioConnTrans(s_currAGConnHdl))
			   {
				   printf("Mute off HFP connection successfully and please pay attention to audio card switching.\n");
			   }
			   else
			   {
				   printf("Cannot mute off HFP connection and an error occurs.\n");
			   }
		   } 
		   break;

	case '2':
		if (BTSDK_INVALID_HANDLE == s_currAGConnHdl)
		{
			printf("If there is not a connection existing, please establish a connection first.\n");
			break;
		}
		PrintErrorMessage(Btsdk_Disconnect(s_currAGConnHdl), BTSDK_TRUE);
        s_currHFConnHdl = BTSDK_INVALID_HANDLE;
		break;
		
	default:
		printf("Invalid command.\n");
		break;
	}
}
Exemple #4
0
/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Description:
	This function is the execution function for HFP device sample.
Arguments:
	BTUINT8 choice
Return:
	void 
---------------------------------------------------------------------------*/
void HfpAPExecCmd(BTUINT8 choice)
{
	BTUINT8 buf[32];
	BTUINT32 res = 0;
	memset(buf, 0, 32);

	switch (choice)
	{
	case '1': // Answer the incoming call
		Btsdk_HFAP_AnswerCall(s_currHFConnHdl);
		break;
	case '2': // Reject the incoming call or terminate an outgoing call or release an ongoing call
		Btsdk_HFAP_CancelCall(s_currHFConnHdl);
		break;
	case '3': // Please dial with a phone number
		printf("Input the phone number: ");
		scanf("%s", buf);
		if (strlen(buf) != 0)
		{
			Btsdk_HFAP_Dial(s_currHFConnHdl, buf, (BTUINT16)strlen(buf));
		}
		break;
	case '4': // Last number redial
		Btsdk_HFAP_LastNumRedial(s_currHFConnHdl);
		break;
	case '5': // Memory dialing
		printf("Input the memory location: ");
		scanf("%s", buf);
		if (strlen(buf) != 0)
			Btsdk_HFAP_MemNumDial(s_currHFConnHdl, buf, (BTUINT16)strlen(buf));
		break;
	case '6': // Transmit DTMF
		printf("Input the DTMF digit: ");
		do {
			scanf("%c", buf);
		} while (buf[0] == '\n');
		if ((buf[0] >= '0' && buf[0] <= '9') || buf[0] == '*' || buf[0] == '#')
			Btsdk_HFAP_TxDTMF(s_currHFConnHdl, buf[0]);
		break;
	case '7':
		printf("Turn microphone volume of cell phone to the Max.");
		Btsdk_HFAP_SetMicVol(s_currHFConnHdl, '15');
		break;
	case '8':
		printf("Turn speaker volume of cell phone to the Max.");
		Btsdk_HFAP_SetSpkVol(s_currHFConnHdl, '15');
		break;
	case '9': // Disable the EC and NR on AG
		Btsdk_HFAP_DisableNREC(s_currHFConnHdl);
		break;
	case 'a': // Request for Current Network Operator Name
		Btsdk_HFAP_NetworkOperatorReq(s_currHFConnHdl);
		// The network operator name will be returned by BTSDK_HFP_EV_NETWORK_OPERATOR_IND event.
		break;
	case 'b': // SCO Audio Switching
		Btsdk_HFAP_AudioConnTrans(s_currHFConnHdl);
		break;
	case 'c': // Request for Subscriber Info
		res = Btsdk_HFAP_GetSubscriberNumber(s_currHFConnHdl);
		// The subscriber info will be returned by BTSDK_HFP_EV_SUBSCRIBER_NUMBER_IND event.
		break;
	case 'd': // Request for current call list
		res = Btsdk_HFAP_GetCurrentCalls(s_currHFConnHdl);
		// The information of each existing call will be returned by BTSDK_HFP_EV_CURRENT_CALLS_IND event.
		break;
	case 'e': // Request for manufacturer and model ID
		{
			BTUINT8 *m_id;
			BTUINT16 m_len = 0;
			res = Btsdk_HFAP_GetManufacturerID(s_currHFConnHdl, NULL, &m_len);
			if (m_len != 0)
			{
				m_id = (BTUINT8*)malloc(m_len);
				memset(m_id, 0, m_len);
				Btsdk_HFAP_GetManufacturerID(s_currHFConnHdl, m_id, &m_len);
				printf("HF-->Manufacturer of the AG is: %s\n>", m_id);
				free(m_id);
			}
			m_len = 0;
			Btsdk_HFAP_GetModelID(s_currHFConnHdl, NULL, &m_len);
			if (m_len != 0)
			{
				m_id = (BTUINT8*)malloc(m_len);
				memset(m_id, 0, m_len);
				Btsdk_HFAP_GetModelID(s_currHFConnHdl, m_id, &m_len);
				printf("HF-->Model ID of the AG is: %s\n>", m_id);
				free(m_id);
			}
			break;
		}
	case 'f': //AT command
		{
			BTUINT8 *ext_cmd = (BTUINT8*)malloc(256);
			printf("Input the AT command: ");
			scanf("%s", ext_cmd);
			if (strlen(ext_cmd) != 0)
			{
				strcat(ext_cmd, "\r");
				Btsdk_HFP_ExtendCmd(s_currHFConnHdl, ext_cmd, (BTUINT16)strlen(ext_cmd), 6000);
				// After this command is transmited and before receiving one of "OK", "ERROR" or "+CMER", 
				// all the result codes responded by AG will be returned by BTSDK_HFP_EV_EXTEND_CMD_IND event.
				// The ending "OK", "ERROR" or "+CMER" will also be returned by BTSDK_HFP_EV_EXTEND_CMD_IND event.
			}
			free(ext_cmd);
			break;
		}
	case 'g': // Attach a phone number to a voice tag
		res = Btsdk_HFAP_VoiceTagPhoneNumReq(s_currHFConnHdl);
		// The phone number will be returned by BTSDK_HFP_EV_VOICETAG_PHONE_NUM_IND event.
		break;
	case 'h': // Activate or deactivate voice recognition
		s_hf_bvra_enable = s_hf_bvra_enable ^ 1;
		Btsdk_HFAP_VoiceRecognitionReq(s_currHFConnHdl, s_hf_bvra_enable);
		break;
	case 'i':
		if (BTSDK_INVALID_HANDLE == s_currHFConnHdl)
		{
			printf("If there is not a connection existing, please establish a connection first.\n");
			break;
		}
		PrintErrorMessage(Btsdk_Disconnect(s_currHFConnHdl), BTSDK_TRUE);
        s_currHFConnHdl = BTSDK_INVALID_HANDLE;
		break;
	default:
		printf("**Invalid Command!**\n>");
		break;
	}
}