Exemple #1
0
/*---------------------------------------------------------------------------
 *            AvrcpRegisterSdp()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Registers an SDP entry.
 *
 * Return:    BT_STATUS_FAILED
 *            (Also see SDP_AddRecord)
 */
BtStatus AvrcpRegisterSdp(AvrcpChannel *Chnl, U8 version)
{
    BtStatus    status;
    SdpRecord  *sdpRecord;
    U8 local_service_id = version; /* for temportary used. */
    
    /* Configure the attributes */
    kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_REGISTER , Chnl->role);

    switch (Chnl->role) {
    case AVRCP_TG: // register the target role
        if (AVRCP(tgChannelCount)++ > 0) 
            return BT_STATUS_SUCCESS;

        AVRCP(tgSdpRecord).num = SDPDB_GetLocalServiceAttribute(
                                                                SC_AV_REMOTE_CONTROL_TARGET,
                                                                &AVRCP(tgSdpRecord).attribs,
                                                                &local_service_id
                                                                );  
        
        sdpRecord = &AVRCP(tgSdpRecord);
		status = SDP_AddRecord(sdpRecord);
		OS_Report("[AVRCP] register TG status:%d", status);
        break;
    case AVRCP_CT:
        if (AVRCP(ctChannelCount)++ > 0) 
            return BT_STATUS_SUCCESS;

        /* Copy the SDP attributes to RAM */
        AVRCP(tgSdpRecord).num = SDPDB_GetLocalServiceAttribute(
                                                                SC_AV_REMOTE_CONTROL,
                                                                &AVRCP(ctSdpRecord).attribs,
                                                                &local_service_id
                                                                );  
        sdpRecord = &AVRCP(ctSdpRecord);
#if 0
		sdpRecord->classOfDevice = 0;
#endif
	    status = SDP_AddRecord(sdpRecord);
		OS_Report("[AVRCP] register CT status:%d", status);

        break;

    default:
        status = BT_STATUS_FAILED;
        goto fail;
    }


fail:
    return status;
}
Exemple #2
0
/*****************************************************************************
 * FUNCTION
 *  AttDeviceSdpDB_Registration
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
U8 AttDeviceSdpDB_Registration(void)
{
    BtStatus status;

    Report(("[ATT] AttDeviceSdpDB_Registration()"));
    BT_AttRecord.registered = TRUE;
    BT_AttRecord.record.num = sizeof(AttSdpAttributes) / sizeof(*(AttSdpAttributes));
    /* Retrieve the server channel from the service channel */
    BT_AttRecord.record.attribs = (SdpAttribute*) & AttSdpAttributes;
    status = SDP_AddRecord(&BT_AttRecord.record);
    Assert((status != BT_STATUS_INVALID_PARM));
    kal_trace(TRACE_GROUP_1, SDP_REG_RESULTx02X, status);
    return (U8)status;
}
Exemple #3
0
/*****************************************************************************
 * FUNCTION
 *  BTAppHandleRegisterRecord
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ptr     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void BTAppHandleRegisterRecord(bt_app_sdpdb_register_req_struct *ptr)
{
    U32 handle = 0;
    U8 type = 0;
    U8 *record_raw = NULL;
    U16 record_raw_length = 0;
    U8 *attribs_buffer = NULL;
    U16 attribs_buffer_size = 0;
    U8 record_index = 0, i = 0;
    U8 attribute_no = 0;
    U8 *record_attribute_ptr = 0;
    BtStatus status = BT_STATUS_FAILED;
    SdpAttribute *attribs_ptr = NULL;
    SdpRecord *service_record = 0;
    BT_APP_ATTRIBUTE_struct_t attribute_buffer[BT_APP_MAX_ATTRIBUTE_SIZE];

    OS_MemSet((U8*) attribute_buffer, 0, sizeof(BT_APP_ATTRIBUTE_struct_t) * BT_APP_MAX_ATTRIBUTE_SIZE);

    handle = ptr->handle;
    type = ptr->type;
#ifndef BTMTK_ON_LINUX 
    record_raw = ptr->record_raw;
    record_raw_length = ptr->record_raw_length;
    /* ptr->attribs: points to the memory space is allocated by JBT and this buffer space is used to registration SDP record */
	/* android no shared memory management yet */
    attribs_buffer = ptr->attribs_buffer;
    attribs_buffer_size = ptr->attribs_buffer_size;
#endif

    for (i = 0; i < BT_SDPDB_MAX_SERVICE_RECORD_NO; i++)
    {
        /* Check free and available service record */
        /*
         * bt_app_sdpdb_context.db[i].AppRecordHandler: It is just for Java Application to identify
         * Before java application registration its sdp record, it must obtain this AppRecordHandler first to ensure one available entry can be used to register to native BT SDPDB
         * The actual service record handle published to other device is determined by SDP_AddRecord()'s SDPS(nextHandle) in native BT stack
         */
        if ((bt_app_sdpdb_context.db[i].used != 0) && (bt_app_sdpdb_context.db[i].AppRecordHandler == handle))
        {
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_FIND_INDEX_I_AVAILABLEx02X, i);
            record_index = i;
#ifdef BTMTK_ON_LINUX  /* android no shared memory management yet */
            attribs_buffer = bt_app_sdpdb_context.db[i].attribute_value;
            attribs_buffer_size = BT_APP_MAX_RECORD_SIZE;
            memcpy(bt_app_sdpdb_context.db[i].raw_data, ptr->record_raw, ptr->record_raw_length);
            record_raw = bt_app_sdpdb_context.db[i].raw_data;
            record_raw_length = ptr->record_raw_length;
#endif
            break;
        }
    }
    if (i == BT_SDPDB_MAX_SERVICE_RECORD_NO)
    {
        kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_NO_AVAILABLE_SERVICE_RECORD);
        /* No available service record  */
        BTAppHandleRegisterRecordResult(BTSDPDBAPP_INVALID_HANDLE, handle);
        return;
    }
    service_record = &bt_app_sdpdb_context.db[i].AppSdpRecord;
    Assert(service_record != 0);

    if (record_raw_length > BT_APP_MAX_RECORD_SIZE)
    {
        BTAppHandleRegisterRecordResult(BTSDPDBAPP_SDP_RECORD_TOO_LARGE, handle);
        return;
    }
    if (BTAppVerifyApplicationRecord(record_raw, record_raw_length, &attribute_no, (U8*) & attribute_buffer))
    {
        kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_THE_ATTRIBUTE_NO_ISx02X, attribute_no);
        if (attribs_buffer_size < sizeof(SdpAttribute) * attribute_no)
        {
            BTAppHandleRegisterRecordResult(BTSDPDBAPP_SDP_RECORD_ATTRIBUTE_BUFFER_TOO_SMALL, handle);
            return;
        }
        if (type == BT_APP_UPDATE_RECORD)
        {
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_UPDATE_THE_RECORD);
            status = SDP_RemoveRecord(&(bt_app_sdpdb_context.db[i].AppSdpRecord));
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_REMOVE_STATUSxD, status);
        }
        /* points to memory space allocated in JBT and this buffer will not freed until to deregister this record */
#ifndef BTMTK_ON_LINUX  /* android no shared memory management yet */
        bt_app_sdpdb_context.db[i].attribute_value = attribs_buffer;
#endif
        record_attribute_ptr = bt_app_sdpdb_context.db[i].attribute_value;

        /* Once return from BTAppVerifyApplicationRecord() successfully, the atrribute_buffer stores the valid syntax attribute id and its corresponding atrribute value */
        /* The attribute_no will not include the aid = 0x0000, because the service_record_handle attribute will not obtain from app */
        for (i = 0; i < attribute_no; i++)
        {
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_INDEXxD, i);
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_ATTRIBUTE_IDxD, attribute_buffer[i].attribute_id);
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_ATTRIBUTE_SIZExD, attribute_buffer[i].attribute_size);
            attribs_ptr = (SdpAttribute*) (record_attribute_ptr + i * sizeof(SdpAttribute));
            attribs_ptr->id = attribute_buffer[i].attribute_id;
            attribs_ptr->len = attribute_buffer[i].attribute_size;
            attribs_ptr->value = attribute_buffer[i].attribute_value;
            attribs_ptr->flags = 0x0000;
        }
        bt_app_sdpdb_context.db[record_index].AppSdpRecord.num = attribute_no;
        bt_app_sdpdb_context.db[record_index].AppSdpRecord.attribs =
            (SdpAttribute*) bt_app_sdpdb_context.db[record_index].attribute_value;
        status = SDP_AddRecord(&(bt_app_sdpdb_context.db[record_index].AppSdpRecord));
        kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_SDP_ADDRECORD_STATUSx02X, status);
        if (status == BT_STATUS_SUCCESS)
        {
            BTAppHandleRegisterRecordResult(BTSDPDBAPP_SUCCESS, handle);
        }
        else
        {
            BTAppHandleRegisterRecordResult(BTSDPDBAPP_SDP_REGISTER_FAILED, handle);
        }
    }
    else
    {
        BTAppHandleRegisterRecordResult(BTSDPDBAPP_SDP_RECORD_SYNTAX_ERROR, handle);
        kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_REG_RECORD_RECORD_PARSE_ERROR);
    }
}