hi there

I am trying to search my mobile phone for bluetooth services. I have copied some code from


and have changed the mac address to my phones mac address and the 0xABCD to 0x1105 which seems to be the obexpush code in bluez (I'm not sure if I need to change this number). The problem is that although the phone shows some bluetooth activity when I initiate the code I get no output showing me the obex push service so that I can get the 'channel/port' which is all I want.

I am using slackware 2.6.18 by the way

Here is the script I am using

#include <bluetooth/bluetooth.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>

int main(int argc, char **argv)
uint32_t svc_uuid_int[] = { 0x0, 0x0, 0x0, 0x1105 };
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( "xx:xx:xx:xx:xx:xx", &target );

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

// 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;

// go through each of the service records
for (; r; r = r->next ) {
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 );
case SDP_UINT8:
if( proto == RFCOMM_UUID ) {
printf("rfcomm channel: %d\n",d->val.int8);
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 );


I am quite a novice at doing this in C as I am used to using bash/shell script and using sdptool. However I am trying to learn C and am using this as a project.

Thanks in advance