Exemple #1
0
/*---------------------------------------------------------------------------
 *            HidSdpCallback()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Makes a callback to the application with query response.
 */
void HidSdpCallback(HidChannel *Channel, BtStatus Status)
{
    /* Indicate the query response to the application */
    HidAppCallback(Channel, HIDEVENT_QUERY_CNF, Status,
                   &Channel->queryRsp, (U16)(sizeof(HidQueryRsp)));

    hid_free(Channel->queryRsp.descriptorList);
    btmtk_os_memset((U8 *)&Channel->queryRsp, 0, sizeof(Channel->queryRsp));
}
Exemple #2
0
void Hid_Free_Mem()
{
	int i;
	for(i = 0; i < MAX_KEY_ARRAY_SIZE; i++)
	{
		if(keyArySet[i].firstAry == 1)
		{
			bt_prompt_trace(MOD_BT,"[HID]Free the array table");
			hid_free(keyArySet[i].keyAry);
			keyArySet[i].firstAry = 0;
		}
		keyArySet[i].keyAry = NULL;
		keyArySet[i].keyAryIndex = 0;
		keyArySet[i].reportID = 0;
	}
}
Exemple #3
0
void HidSdpEventHandler(SdpQueryToken *sqt, U8 result, U8 attr_idx, U8 *attr_val)
{
    HidChannel     *channel = ContainingRecord(sqt, 
                                               HidChannel, sdpQueryToken);
    ReportDescriptorList* reportDescriptorList = NULL;
    HidParseData*	hpd ;
    kal_trace(BT_TRACE_G2_PROFILES,BT_HID_SDP_QUERY_CALLBACK_x02X ,result);

    switch (result) 
    {
        case BT_STATUS_SDP_CONT_STATE:
            kal_trace(BT_TRACE_G2_PROFILES,HID_SDP_SUCCESSFULLY);
            HidVerifySdpQueryRsp(channel, bt_hid_attr_id_list[attr_idx], attr_val, sqt->availValueLen, result);  
            break;

        case BT_STATUS_SUCCESS:
            HidVerifySdpQueryRsp(channel, bt_hid_attr_id_list[attr_idx], attr_val, sqt->availValueLen, result);
            if (channel->bSDPDiscPending)
            {
                HidClearConnection(channel, result, 0);
            }
            else 
            {
				hpd = (HidParseData*)hid_malloc(sizeof(HidParseData));
				Hid_Init_Parser(hpd);
                		channel->reportCons[0] = (HidReportConstructor*)hid_malloc(HID_REPORT_ID_MAX * sizeof(HidReportConstructor));
				btmtk_os_memset((U8*) channel->reportCons[0], 0, HID_REPORT_ID_MAX * sizeof(HidReportConstructor));

				reportDescriptorList = HidFindReportDescriptorByAddr(channel->cmgrHandler.remDev->bdAddr);
				
				if(reportDescriptorList != NULL )
				{		
					btmtk_os_memset(reportDescriptorList->BtAddr.addr, 0, 6);
					reportDescriptorList->inUse = FALSE;
					hid_free(reportDescriptorList->reportDescriptor);
					reportDescriptorList->reportDescriptorLength = 0;
				}
				
				HidCacheReportDescriptor(channel->cmgrHandler.remDev->bdAddr, channel->queryRsp.descriptorList, channel->queryRsp.descriptorLen);
				
        		if(HidAddDescriptor(channel) == BT_STATUS_SUCCESS)
        			bt_prompt_trace(MOD_BT,"[HID]HidAddDescriptor Successed!");
        		else
        			bt_prompt_trace(MOD_BT,"[HID]HidAddDescriptor failed!");   
                
				Hid_Free_Parser(hpd);
                channel->flags &= ~CHNL_FLAG_SERVICE_QUERY;
                HidSdpCallback(channel, result);
            }
            break;
		case BT_STATUS_NOSERVICES:
			{
				static const U8 HidDescriptorList[] = 
				{
				    HID_DESCRIPTOR
				};
				channel->queryRsp.descriptorLen = HID_DESCRIPTOR_LEN;
				channel->queryRsp.descriptorList = (U8*)hid_malloc(HID_DESCRIPTOR_LEN);
				btmtk_os_memset((U8*) channel->queryRsp.descriptorList, 0, HID_DESCRIPTOR_LEN);				
				btmtk_os_memcpy((U8*) channel->queryRsp.descriptorList, HidDescriptorList, HID_DESCRIPTOR_LEN);
				hpd = (HidParseData*)hid_malloc(sizeof(HidParseData));
				Hid_Init_Parser(hpd);
                		channel->reportCons[0] = (HidReportConstructor*)hid_malloc(HID_REPORT_ID_MAX * sizeof(HidReportConstructor));
				btmtk_os_memset((U8*) channel->reportCons[0], 0, HID_REPORT_ID_MAX * sizeof(HidReportConstructor));

                if(HidAddDescriptor(channel) == BT_STATUS_SUCCESS)
                    bt_prompt_trace(MOD_BT,"[HID]HidAddDescriptor Successed!");
                else
                    bt_prompt_trace(MOD_BT,"[HID]HidAddDescriptor failed!");
                
				Hid_Free_Parser(hpd);
                channel->flags &= ~CHNL_FLAG_SERVICE_QUERY;
                HidSdpCallback(channel, BT_STATUS_SUCCESS);
				break;
			}
        case BT_STATUS_CONNECTION_FAILED:
        case BT_STATUS_FAILED:
        default:
            channel->flags &= ~CHNL_FLAG_SERVICE_QUERY;
            HidClearConnection(channel, result, 0);
            break;
    }

}