Ejemplo n.º 1
0
/*****************************************************************************
 * FUNCTION
 *  BTAppSdpDbDeactivate
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  void
 *****************************************************************************/
void BTAppSdpDbDeactivate(void)
{
    U8 i = 0;
    U32 handle;

    for (i = 0; i < BT_SDPDB_MAX_SERVICE_RECORD_NO; i++)
    {
        if ((bt_app_sdpdb_context.db[i].used != 0))
        {
            handle = bt_app_sdpdb_context.db[i].AppRecordHandler;
            /* Find matched service record */
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_SDPDBDEACTIVATE_FIND_INDEX_I_TO_UNREGISTERx02X, i);
            bt_app_sdpdb_context.db[i].used = 0;
#ifndef BTMTK_ON_LINUX  /* android no shared memory management yet */
            bt_app_sdpdb_context.db[i].attribute_value = 0;
#endif
            SDP_RemoveRecord(&(bt_app_sdpdb_context.db[i].AppSdpRecord));
            /* Remove break statement: Because each entry must be reset: 2008-0102 */
        }
    }
    OS_MemSet((void*)&(bt_app_sdpdb_context), 0, sizeof(bt_app_sdpdb_context));

    /* The following are codes of AppSdpDBInit() */
    for (i = 0; i < BT_SDPDB_MAX_SERVICE_RECORD_NO; i++)
    {
        bt_app_sdpdb_context.db[i].AppRecordHandler = 0x00010030 + i;
    }
}
Ejemplo n.º 2
0
/*****************************************************************************
 * FUNCTION
 *  AttDeviceSdpDB_DeRegistration
 * DESCRIPTION
 *  
 * PARAMETERS
 *  void
 * RETURNS
 *  
 *****************************************************************************/
U8 AttDeviceSdpDB_DeRegistration(void)
{
    BtStatus status;

    status = SDP_RemoveRecord(&BT_AttRecord.record);
    return (U8)status;
}
Ejemplo n.º 3
0
/*---------------------------------------------------------------------------
 *            AvrcpDeregisterSdp()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Deregisters an SDP entry.
 *
 * Return:    BT_STATUS_FAILED
 *            (Also see SDP_RemoveRecord)
 */
BtStatus AvrcpDeregisterSdp(AvrcpChannel *Chnl)
{
    BtStatus status = BT_STATUS_SUCCESS;
    kal_trace( BT_TRACE_G8_AVRCP, BT_AVRCP_SDP_DEREGISTER, Chnl->role);

    if (Chnl->role == AVRCP_CT) {
        if (--AVRCP(ctChannelCount) == 0) {
            status = SDP_RemoveRecord(&AVRCP(ctSdpRecord));
        }
    } else if (Chnl->role == AVRCP_TG) { // deregister the target role
        if (--AVRCP(tgChannelCount) == 0) {
            status = SDP_RemoveRecord(&AVRCP(tgSdpRecord));
        }
    } else {
        status = BT_STATUS_FAILED;
    }
    OS_Report("AVRCP DeregisterSDP status:%d", status);
    return status;
}
Ejemplo n.º 4
0
/*****************************************************************************
 * FUNCTION
 *  BTAppHandleDeRegisterRecord
 * DESCRIPTION
 *  
 * PARAMETERS
 *  ptr     [IN]        
 * RETURNS
 *  void
 *****************************************************************************/
void BTAppHandleDeRegisterRecord(bt_app_sdpdb_deregister_req_struct *ptr)
{
    U8 i = 0;
    BtStatus status = BT_STATUS_FAILED;
    U32 handle = 0;

    handle = ptr->handle;

    for (i = 0; i < BT_SDPDB_MAX_SERVICE_RECORD_NO; i++)
    {
        if ((bt_app_sdpdb_context.db[i].used != 0) && (bt_app_sdpdb_context.db[i].AppRecordHandler == handle))
        {
            /* Find matched service record */
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_DEREG_RECORD_FIND_INDEX_I_TO_UNREGISTERx02X, i);

            bt_app_sdpdb_context.db[i].used = 0;
#ifdef BTMTK_ON_LINUX  /* android no shared memory management yet */
            OS_MemSet(bt_app_sdpdb_context.db[i].attribute_value, 0, BT_APP_MAX_RECORD_SIZE);
            OS_MemSet(bt_app_sdpdb_context.db[i].raw_data, 0, BT_APP_MAX_RECORD_SIZE);
#else
            bt_app_sdpdb_context.db[i].attribute_value = 0;
#endif
            status = SDP_RemoveRecord(&(bt_app_sdpdb_context.db[i].AppSdpRecord));
            kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_DEREG_RECORD_STATUSx02X, status);
            break;
        }
    }
    if (i == BT_SDPDB_MAX_SERVICE_RECORD_NO)
    {
        kal_trace(BT_TRACE_JSR82_GROUP, BT_JSR82_DEREG_RECORD_NO_REGISTERED_SERVICE_RECORD);
        BTAppHandleDeRegisterRecordResult(BTSDPDBAPP_INVALID_HANDLE, handle);
        return;
    }
    if (status == BT_STATUS_INVALID_PARM)
    {
        BTAppHandleDeRegisterRecordResult(BTSDPDBAPP_FAILED, handle);
    }
    else if (status == BT_STATUS_FAILED)
    {
        BTAppHandleDeRegisterRecordResult(BTSDPDBAPP_SDP_DEREGISTER_FAILED, handle);
    }
    else
    {
        BTAppHandleDeRegisterRecordResult(BTSDPDBAPP_SUCCESS, handle);
    }
}
Ejemplo n.º 5
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);
    }
}
Ejemplo n.º 6
0
void test_db_api_sample_3(void)
{
  u_int32 handle;

  u_int16 _16bit;
  u_int8 _8bit;
  
  t_SDP_serviceRecord *pRecord;
  t_SDP_dataElement e1,e2,e3,e4;
  
  t_SDP_dataElement* list[10];
  
  char Service_name[] = "A sample database";

  handle = 0x00010002;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  _16bit = 0x2323;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  

  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  SDP_AddAttribute(pRecord,0x0001,&e3);
  
  /* protocol descriptor list */

  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  _16bit = 0x0003;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  _8bit = 0x01;
  
  SDP_EncodeAttribute(SDP_UINT,1,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e3;

  SDP_CreateList(SDP_SEQUENCE,2,list,&e4);
  
  _16bit = 0x0008;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  list[0] = &e2;
  list[1] = &e4;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e1);
  
  SDP_AddAttribute(pRecord,0x0004,&e1);

  /* browse group */

  _16bit = 0x1002;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  SDP_AddAttribute(pRecord,0x0005,&e2);

  /* language base */

  _16bit = ('e' << 8) + 'n';

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e1);

  _16bit = 106;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);
   
  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e2;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e4);

  SDP_AddAttribute(pRecord,0x0006,&e4);

  /* profile - list */

  _16bit = 0x1105;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  _16bit = 0x0100;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);

  list[0] = &e1;
  list[1] = &e2;
  
  SDP_CreateList(SDP_SEQUENCE,2,list,&e3);

  SDP_AddAttribute(pRecord,0x0009,&e3);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name) -1,Service_name,&e1);

  SDP_AddAttribute(pRecord,0x0100,&e1);


  /*  Now to remove the record */

  SDP_RemoveRecord(0x00010003);
}