2006-10-04 15:14:26

by Andrea Carlevato

[permalink] [raw]
Subject: [Bluez-devel] SDP browsing a 128 bit UUID ???

Hello,
i ve this problem:

i neet to write a simple code to search a sdp record on
my cell phone, identified by a 128 bit UUID and loaded
by a java midlet.
In particular, the UUID is:
f07122bf9a648cf8082c0553b183326

i wrote this code, 00:11:9F:B0:EA:02 is the MAC of my phone.
But when i run it, value of "err" after 'sdp_service_search_attr_req'
is always 0, and the response list seem to be empty.
Can someone tell me if it's a wrong code ??

thanks a lot
Andrea


-----------------------------------------------------

void sdp_search()
{
uint32_t svc_uuid_int[] = { 0xf07122bf, 0x09a648cf, 0x8082c055,
0x3b183326 };
uuid_t svc_uuid;
int err;
bdaddr_t target;
sdp_list_t *response_list = NULL, *search_list, *attrid_list;
sdp_session_t *session = 0;

str2ba( "00:11:9F:B0:EA:02", &target );

// connect to the SDP server running on the remote machine
printf("SDP Connecting\n");
session = sdp_connect( BDADDR_ANY, &target, SDP_RETRY_IF_BUSY );
printf("SDP Connecting\n");


// specify the UUID of the application we're searching for
sdp_uuid128_create( &svc_uuid, &svc_uuid_int );
search_list = sdp_list_append( NULL, &svc_uuid );

// specify that we want a list of all the matching applications'
attributes
uint32_t range = 0x0000ffff;
attrid_list = sdp_list_append( NULL, &range );

// get a list of service records that have UUID 0xabcd
err = sdp_service_search_attr_req( session, search_list, \
SDP_ATTR_REQ_RANGE, attrid_list, &response_list);

sdp_list_t *r = response_list;
printf("COMPLETE: %d\n", err);
// go through each of the service records
for (; r; r = r->next ) {
printf("RECORD\n");
sdp_record_t *rec = (sdp_record_t*) r->data;
sdp_list_t *proto_list;

// get a list of the protocol sequences
if( sdp_get_access_protos( rec, &proto_list ) == 0 ) {
sdp_list_t *p = proto_list;

// go through each protocol sequence
for( ; p ; p = p->next ) {
sdp_list_t *pds = (sdp_list_t*)p->data;

// go through each protocol list of the protocol sequence
for( ; pds ; pds = pds->next ) {

// check the protocol attributes
sdp_data_t *d = (sdp_data_t*)pds->data;
int proto = 0;
for( ; d; d = d->next ) {
switch( d->dtd ) {
case SDP_UUID16:
case SDP_UUID32:
case SDP_UUID128:
proto = sdp_uuid_to_proto( &d->val.uuid );
break;
case SDP_UINT8:
if( proto == RFCOMM_UUID ) {
printf("rfcomm channel: %d\n",d->val.int8);
}
break;
}
}
}
sdp_list_free( (sdp_list_t*)p->data, 0 );
}
sdp_list_free( proto_list, 0 );

}

printf("found service record 0x%x\n", rec->handle);
sdp_record_free( rec );
}

sdp_close(session);

}


Attachments:
(No filename) (3.11 kB)
(No filename) (6.58 kB)
(No filename) (348.00 B)
(No filename) (164.00 B)
Download all attachments