Exemplo n.º 1
0
/*---------------------------------------------------------------------------
 *            HidSdpparse16Bit()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Parses the SDP query response for an 16 bit value.
 *
 * Return:    (see SDP_ParseAttributes)
 */
static void HidSdpParse16Bit(HidChannel *Channel, U8 *in_value, 
                                 U16 AttribId, U16 QueryFlag, U16 *out_value)
{
    if (in_value == NULL)
    {
        return;
    }

    if (!(Channel->queryRsp.queryFlags & QueryFlag)) {

        /* We had better have a U16 version */
        *out_value = SDP_GetU16(in_value);

        kal_trace(BT_TRACE_G2_PROFILES,HID_SDP_PARSEATTRIBUTES_SUCCEEDED_VALUE__0Xx04XUPDATED_BUFF_LEN__xD , *out_value, 
                2);

        Channel->queryRsp.queryFlags |= QueryFlag;

    }

}
Exemplo n.º 2
0
// data is the attribute_value passed from the SDP callback.
// The formate of a profile descriptor is: 
BtStatus parseAvrcpVersion(U8 *data, U16 *version)
{
	BtStatus status = BT_STATUS_FAILED;
	
    U8 type = 0;
    U16 local_pos = 0, offset = 0, len = 0;
    U16 value_len = 0;
    U16 uuid16 = 0;
    U32 uuid32 = 0;
    U8 uuid128[16] = {0};

    
    type = SDP_GetElemType(data[local_pos]);
	len = SDP_ParseDataElement(&data[local_pos], &offset);
	
	OS_Report("[AVRCP] %s() type: %d, len: %d", __FUNCTION__, type, len);
	
	local_pos += offset;
	type = SDP_GetElemType(data[local_pos]);
	if (type == DETD_UUID) {
		value_len = SDP_ParseDataElement(&data[local_pos], &offset);
		local_pos += offset;
		
		// Print out the UUID field. Checking function can be added here.
        switch (value_len) {
            case 2:
                uuid16 = SDP_GetU16(&data[local_pos]);
                OS_Report("[AVRCP] %s() UUID16: 0x%04x", __FUNCTION__, uuid16);
                break;
            case 4:
                uuid32 = SDP_GetU32(&data[local_pos]);
                OS_Report("[AVRCP] %s() UUID32: 0x%08x", __FUNCTION__, uuid32);
                break;
            case 16:
                OS_MemCopy(uuid128, &data[local_pos], 16);
                OS_Report("[AVRCP] %s() UUID128: %02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x",
                    __FUNCTION__,
                    data[local_pos], data[local_pos + 1], data[local_pos + 2], data[local_pos + 3],
                    data[local_pos + 4], data[local_pos + 5], data[local_pos + 6], data[local_pos + 7],
                    data[local_pos + 8], data[local_pos + 9], data[local_pos + 10], data[local_pos + 11],
                    data[local_pos + 12], data[local_pos + 13], data[local_pos + 14], data[local_pos + 15]);
                break;
            default:
                OS_Report("[AVRCP] %s() Invalide uuid_len: %d", __FUNCTION__, value_len);
                return status;
        }    
        local_pos += value_len;
        
	} else {
		OS_Report("[AVRCP] %s() Invalid type: %d when parsing uuid.", __FUNCTION__, type);
	}

    	
	type = SDP_GetElemType(data[local_pos]);
	len = SDP_ParseDataElement(&data[local_pos], &offset);
	if (type == DETD_UINT) {
		local_pos += offset;
		*version = SDP_GetU16(&data[local_pos]);
		OS_Report("[AVRCP] %s() version:0x%x", __FUNCTION__, *version);
		status = BT_STATUS_SUCCESS;
		
	} else {
		OS_Report("[AVRCP] %s() Invalid type: %d when parsing version.", __FUNCTION__ , type);
	}
	
	return status;
}