/****************************************************************************
NAME	
    connectionHandleReadClkOffsetComplete

DESCRIPTION
    Confirm containing the remote clock offset if the read request succeeded.

RETURNS
    void
*/
void connectionHandleReadClkOffsetComplete(connectionReadInfoState *state, const DM_HCI_READ_CLOCK_OFFSET_COMPLETE_T *cfm)
{
	/* Tell the application about the outcome of the read clock offset request */
	sendClockOffsetCfm(state->stateInfoLock, connectionConvertHciStatus(cfm->status), cfm->clock_offset, state->sink);

	/* Reset the lock */
	state->stateInfoLock = 0;
	state->sink = 0;
}
/****************************************************************************
NAME	
    connectionHandleReadRssiComplete

DESCRIPTION
    Confirm containing the RSSI value if the read request succeeded.

RETURNS
    void
*/
void connectionHandleReadRssiComplete(connectionReadInfoState *state, const DM_HCI_READ_RSSI_COMPLETE_T *cfm)
{
	/* Pass the result to the app */
	sendRssiCfm(state->stateInfoLock, connectionConvertHciStatus(cfm->status), cfm->rssi, state->sink);

	/* Reset the lock */
	state->stateInfoLock = 0;
	state->sink = 0;
}
/****************************************************************************
NAME	
    connectionHandleReadLinkQualityComplete

DESCRIPTION
    Confirm containing the link quality if the read request succeeded.

RETURNS
    void
*/
void connectionHandleReadLinkQualityComplete(connectionReadInfoState *state, const DM_HCI_GET_LINK_QUALITY_COMPLETE_T *cfm)
{
	/* Let the app know the outcome of the read request */
	sendLinkQualityCfm(state->stateInfoLock, connectionConvertHciStatus(cfm->status), cfm->link_quality, state->sink);

	/* Reset the lock */
	state->stateInfoLock = 0;
	state->sink = 0;
}
/****************************************************************************
NAME	
    connectionHandleReadInquiryTx

DESCRIPTION
    This function handles a read inquiry tx result

RETURNS
    void
*/
void connectionHandleReadInquiryTxComplete(connectionInquiryState *state, const DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM_T *cfm)
{
	if(state->inquiryLock)
	{
		MAKE_CL_MESSAGE(CL_DM_READ_INQUIRY_TX_CFM);
		message->status = connectionConvertHciStatus(cfm->status);
		message->tx_power = cfm->tx_power;
		MessageSend(state->inquiryLock, CL_DM_READ_INQUIRY_TX_CFM, message);
                
                state->inquiryLock = 0;
	}	
}
/****************************************************************************
NAME    
    connectionHandleLocalNameComplete

DESCRIPTION
    Local name result

RETURNS
    void
*/
void connectionHandleLocalNameComplete(connectionInquiryState *state, const DM_HCI_READ_LOCAL_NAME_CFM_T* prim)
{
    /* Providing the read was a success and we have a vaid name */
    if (!prim->status && prim->name_part[0])
    {
        uint16    length;
        uint8    i;

        /* Only handle the first segment */
        char*    name = VmGetPointerFromHandle(prim->name_part[0]);

        /* Find the length of the string in the first segment, limiting to     MAX_NAME_LENGTH bytes */
        for(length = 0; length < MAX_NAME_LENGTH; length++)
        {
            if (name[length] == '\0')
                break;
        }
        
        name[length] = '\0';
        
        /*     Free any other segments */
        for(i = 1;i < HCI_LOCAL_NAME_BYTE_PACKET_PTRS;i++)
        {
            if (prim->name_part[i] != NULL)
                free(VmGetPointerFromHandle(prim->name_part[i]));
        }
        
        /* Remote name read, send Client message to notify them of the result */
        localNameComplete(state->nameLock, connectionConvertHciStatus(prim->status), name, length);
    }
    else
    {
        /* Read failed, send Client message to notify them of the result */
        localNameComplete(state->nameLock, connectionConvertHciStatus(prim->status), NULL, 0);
    }
    
    /* Reset resource lock */
    state->nameLock = 0;
}
예제 #6
0
/****************************************************************************
NAME	
    connectionHandleReadClassOfDeviceComplete

DESCRIPTION
    Handles the read class of device complete message from BlueStack

RETURNS
    void
*/
void connectionHandleReadClassOfDeviceComplete(connectionReadInfoState *state, const DM_HCI_READ_CLASS_OF_DEVICE_CFM_T *cfm)
{
    if (state->stateInfoLock)
    {
        /* Send result to task that originated the request */
        MAKE_CL_MESSAGE(CL_DM_CLASS_OF_DEVICE_CFM);
        message->status = connectionConvertHciStatus(cfm->status);
        message->dev_class = cfm->dev_class;
        MessageSend(state->stateInfoLock, CL_DM_CLASS_OF_DEVICE_CFM, message);
        
        /* Reset the resource lock */
        state->stateInfoLock = 0;
    }
}
/****************************************************************************
NAME	
    connectionHandleReadBdAddrComplete

DESCRIPTION
    Handle a read bd addr complete event

RETURNS
    void
*/
void connectionHandleReadBdAddrComplete(connectionReadInfoState *state, const DM_HCI_READ_BD_ADDR_COMPLETE_T *cfm)
{
    if (state->stateInfoLock)
    {
        /* Send the result to the client */
        MAKE_CL_MESSAGE(CL_DM_LOCAL_BD_ADDR_CFM);
        message->status = connectionConvertHciStatus(cfm->status);
        connectionConvertBdaddr(&message->bd_addr, &cfm->bd_addr);
        MessageSend(state->stateInfoLock, CL_DM_LOCAL_BD_ADDR_CFM, message);
        
        /* Reset the lock */
        state->stateInfoLock = 0;
    }
}
/****************************************************************************
NAME	
    connectionHandleReadRemoteVersionCfm

DESCRIPTION
    Confirm containing the remote version information, if the read request
	succeeded.

RETURNS
    void
*/
void connectionHandleReadRemoteVersionCfm(connectionReadInfoState *state, const DM_HCI_READ_REMOTE_VERSION_COMPLETE_T *cfm)
{
     /* Create and send the message */
     MAKE_CL_MESSAGE(CL_DM_REMOTE_VERSION_CFM);
     message->status = connectionConvertHciStatus(cfm->status);	
     message->lmpVersion       = cfm->LMP_version;
     message->manufacturerName = cfm->manufacturer_name;
     message->lmpSubVersion    = cfm->LMP_subversion;
         
     MessageSend(state->stateInfoLock, CL_DM_REMOTE_VERSION_CFM, message);
 
 	/* Reset the lock */
 	state->stateInfoLock = 0;
 	state->sink = 0;
}
/****************************************************************************
NAME	
    connectionHandleReadRemoteSupportedFeaturesCfm

DESCRIPTION
    Confirm containing the remote supported features, if the read request
	succeeded.

RETURNS
    void
*/
void connectionHandleReadRemoteSupportedFeaturesCfm(connectionReadInfoState *state, const DM_HCI_READ_REMOTE_FEATURES_COMPLETE_T *cfm)
{
	/* Send message up to the client only if the lock is set */
	if (state->stateInfoLock)
	{
		/* 
			Need to check the lock since we get an unsolicited remote features cfm 
			message every time an ACL is opened because BlueStack obtains the remote
			features automatically.
		*/
		sendRemoteSupportedFeaturesCfm(state->stateInfoLock, connectionConvertHciStatus(cfm->status), (const uint16 *) &(cfm->features), state->sink);
	}

	/* Reset the lock */
	state->stateInfoLock = 0;
	state->sink = 0;
}
예제 #10
0
/****************************************************************************
NAME
    connectionHandleReadEirDataComplete

DESCRIPTION
    Handles result from Reading the Extended Inquiry Data.

RETURNS
    void
*/
void connectionHandleReadEirDataComplete(connectionInquiryState *state, const DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM_T *cfm)
{
	if(state->inquiryLock)
	{
		uint8 size_eir_data = 0;
        uint8* eir_data = inquiryParseEir(&size_eir_data, (uint8**)cfm->eir_data_part, FALSE);
		
		MAKE_CL_MESSAGE_WITH_LEN(CL_DM_READ_EIR_DATA_CFM, size_eir_data);
		message->status = connectionConvertHciStatus(cfm->status);
		message->fec_required = cfm->fec_required;
		message->size_eir_data = size_eir_data;
        memmove(message->eir_data, eir_data, size_eir_data);
    	MessageSend(state->inquiryLock, CL_DM_READ_EIR_DATA_CFM, message);
		
		free(eir_data);
	}
	state->inquiryLock = 0;
}
예제 #11
0
/****************************************************************************
NAME	
    connectionHandleSetBtVersionCfm

DESCRIPTION
    Confirm containing the request status and current BT Version

RETURNS
    void
*/
void connectionHandleSetBtVersionCfm(connectionReadInfoState *state, const DM_SET_BT_VERSION_CFM_T *cfm)
{
	if(state->stateInfoLock)
	{	
		if(state->stateInfoLock == connectionGetCmTask())
		{
			/* We finished initialising bt version, continue init process */
			connectionSendInternalInitCfm(connectionInitVer);
		}
		else
		{
			MAKE_CL_MESSAGE(CL_DM_READ_BT_VERSION_CFM);
			message->status = connectionConvertHciStatus(cfm->status);
			message->version = connectionConvertBtVersion(cfm->version);
			MessageSend(state->stateInfoLock,CL_DM_READ_BT_VERSION_CFM, message);	
		}
	}
	
	state->stateInfoLock = 0;
	state->version = cfm->version;
}
예제 #12
0
/****************************************************************************
NAME	
    connectionHandleReadLocalVersionCfm

DESCRIPTION
    Confirm containing the local version information, if the read request
	succeeded.

RETURNS
    void
*/
void connectionHandleReadLocalVersionCfm(connectionReadInfoState *state, const DM_HCI_READ_LOCAL_VERSION_COMPLETE_T *cfm)
{
	if(state->stateInfoLock == connectionGetCmTask())
	{
		/* We got here as part of intialisation, continue version setup */
		if(cfm->hci_version >= HCI_VER_2_1)
		{
			/* Firmware supports 2.1 so can setup the BT version */
			MAKE_CL_MESSAGE(CL_INTERNAL_DM_SET_BT_VERSION_REQ);
			message->theAppTask = connectionGetCmTask();
			message->version = BT_VERSION_2p1;
			MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_SET_BT_VERSION_REQ, message);
		}
		else
		{
			/* Nothing more to be done for version init, continue init process */
			state->version = bluetooth_unknown;
			connectionSendInternalInitCfm(connectionInitVer);
		}
	}
	else
	{
    	/* Create and send the message */
    	MAKE_CL_MESSAGE(CL_DM_LOCAL_VERSION_CFM);
		message->hciVersion = connectionConvertHciVersion(cfm->hci_version);
		message->hciRevision = cfm->hci_revision;
    	message->status = connectionConvertHciStatus(cfm->status);	
    	message->lmpVersion       = cfm->lmp_version;
		message->manufacturerName = cfm->manuf_name;
		message->lmpSubVersion    = cfm->lmp_subversion;
         
		MessageSend(state->stateInfoLock, CL_DM_LOCAL_VERSION_CFM, message);
	}
	/* Reset the lock */
 	state->stateInfoLock = 0;
 	state->sink = 0;
}