From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Thu, 6 Mar 2008 08:49:14 -0800 (PST) From: binta sidibe Reply-To: sidibebinta@yahoo.com Subject: SDP discovery not working To: "marcel@holtmann.org" Cc: "bluez-users@lists.sourceforge.net" , bintasidibeh@hotmail.com MIME-Version: 1.0 Content-Type: text/html; charset=us-ascii Message-ID: <66945.28299.qm@web57404.mail.re1.yahoo.com> List-ID:

hello,

i need help with my bluetooth project. i have two boards TS7300 and i have attached Dlink DT-120 on both. For my project, one is the server and the other is the client. i want to have sevices offered by my server so that my client can just connect to my servers SDP server to get the port numbers. When i hard code the port number i am using, my client can send message to my service...good. Now i went a step ahead and tried to register a service on my server but it fails to connect to local sdp server. 

On my server board...

root@ts7000:root# uname -r
2.4.26-ts11

root@ts7000:root# modprobe bluez
root@ts7000:root# lsmod
Module                  Size  Used by    Not tainted
rfcomm                 31296   0  (unused)
l2cap                  15676   1  [rfcomm]
hci_usb                 8144   0  (unused)
bluez                  30428   1  [rfcomm l2cap hci_usb]
af_packet               9456   0  (unused)
zd                    264068   0  (unused)
open_eth                4448   0  (unused)
tsuart-73               1380   0  (unused)
tsuart0                 9128   0  [tsuart-73]
keybdev                 1772   0  (unused)
hid                    13520   0  (unused)
input                   3320   0  [keybdev hid]
usb-ohci-ep93xx          632   0  (unused)
usb-ohci               15360   0  [usb-ohci-ep93xx]
usbcore                55728   1  [hci_usb zd hid usb-ohci]
pcipool                 1888   1  [usb-ohci-ep93xx usb-ohci]
ts7300fb                3944  63

 

root@ts7000:root# hciconfig hci0 up
root@ts7000:root# hciconfig
hci0:   Type: USB
        BD Address: 00:17:9A:2B:86:8A ACL MTU: 384:8  SCO MTU: 64:8
        UP RUNNING PSCAN ISCAN
        RX bytes:63 acl:0 sco:0 events:7 errors:0
        TX bytes:27 acl:0 sco:0 commands:7 errors:0

 

root@ts7000:root# sdptool browse 00:17:9A:2B:86:8A
Failed to connect to SDP server on 00:17:9A:2B:86:8A: No route to host

 

 

The code that i am using is based on online website. the code is below

 

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/socket.h>
#include </opt/bluetooth/bluetooth.h>
#include </opt/bluetooth/rfcomm.h>
#include </opt/bluetooth/sdp.h>
#include </opt/bluetooth/sdp_lib.h>

 

sdp_session_t* register_service()
{
    uint8_t svc_uuid_int[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
        0, 0, 0xab, 0xcd };
     bdaddr_t target;
     char local[18] = "00:17:9A:2B:86:8A";
     str2ba(local, &target);
     int err = 0, port =0;

 
    uint8_t rfcomm_channel = 11;
    const char *service_name = "Bluetooth Taillight";
    const char *svc_dsc = "An experimental wireless taillight system";
    const char *service_prov = "Wireless Taillight";

    uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid,
           svc_class_uuid;
    sdp_list_t *l2cap_list = 0,
               *rfcomm_list = 0,
               *root_list = 0,
               *proto_list = 0,
               *access_proto_list = 0;
               //*svc_class_list = 0,
               //*profile_list = 0;
    sdp_data_t *channel = 0, *psm = 0;
    printf("Inside registering for service after initiation \n\n");


    //sdp_profile_desc_t profile;
    sdp_record_t *record = sdp_record_alloc();
    if (!record)
    {
 printf("Failed to alloc service record\n\n");
    }
    else
    {
 printf("success to alloc service record \n\n");
    }
 
    sdp_session_t *session = 0;

    // set the general service ID
    sdp_uuid128_create( &svc_uuid, &svc_uuid_int );
    sdp_set_service_id( record, svc_uuid );
    printf("Inside registering for service after setting  up the general service ID\n\n");

   
    // make the service record publicly browsable
    sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
    root_list = sdp_list_append(0, &root_uuid);
    sdp_set_browse_groups( record, root_list );
    printf("Inside registering for service after setting up record publicly browsable\n\n");
   

    // set l2cap information
    sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
    l2cap_list = sdp_list_append( 0, &l2cap_uuid );
    proto_list = sdp_list_append( 0, l2cap_list );

    // register the RFCOMM channel for RFCOMM sockets
    sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
    channel = sdp_data_alloc(SDP_UINT8, &rfcomm_channel);
    rfcomm_list = sdp_list_append( 0, &rfcomm_uuid );
    sdp_list_append( rfcomm_list, channel );
    sdp_list_append( proto_list, rfcomm_list );

   
    // set the name, provider, and description
    sdp_set_info_attr(record, service_name, service_prov, svc_dsc);

    // connect to the local SDP server, register the service record,
    // and disconnect
    //session = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
    if (!(session = sdp_connect(BDADDR_ANY, &target, SDP_RETRY_IF_BUSY)))
    {
 printf("Failed to connect to local server \n\n");
 printf("the  value of session = %d \n", session);
    }
    else
     err = sdp_record_register(session, record, 0);
    //sdp_record_register(session, &record, 0);

    // cleanup
    sdp_data_free( channel );
    sdp_list_free( l2cap_list, 0 );
    sdp_list_free( rfcomm_list, 0 );
    sdp_list_free( root_list, 0 );
    sdp_list_free( access_proto_list, 0 );
    //sdp_list_free( svc_class_list, 0 );
    //sdp_list_free( profile_list, 0 );

    return session;
}

int main()
{

    sdp_session_t* session = register_service();
    printf("After register for service \n\n");
    sleep(5);
    sdp_close( session );
    return 0;
}

 

when i run it,

 

root@ts7000:bluetooth# gcc -o rfcomm-register rfcomm-register.c -lbluetooth
root@ts7000:bluetooth# ./rfcomm-register
Inside registering for service after initiation

success to alloc service record

Inside registering for service after setting  up the general service ID

Inside registering for service after setting up record publicly browsable

Failed to connect to local server

the  value of session = 0
After register for service

Segmentation fault

 

Can someone please tell me what i am doing wrong....

 

 

    



Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.