[maemo-developers] [maemo-developers] Registering bluetooth service
From: Ari Paavilainen arip at iki.fiDate: Mon Feb 13 11:36:08 EET 2006
- Previous message: [maemo-developers] Laika 2.0 released
- Next message: [maemo-developers] Registering bluetooth service
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
Has anyone managed to register a bluetooth service to local sdp server.
I have a piece of code that tries to do that but it fails in call to
sdp_record_register(). Error is 29 = ESPIPE = Illegal seek.
Code (by Albert Huang):
sdp_session_t *register_service()
{
uint32_t service_uuid_int[] = { 0, 0, 0, 0xABCD };
uint8_t rfcomm_channel = 11;
const char *service_name = "Name";
const char *service_dsc = "Description";
const char *service_prov = "Service provider";
uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid;
sdp_list_t *l2cap_list = 0,
*rfcomm_list = 0,
*root_list = 0,
*proto_list = 0,
*access_proto_list = 0;
sdp_data_t *channel = 0, *psm = 0;
sdp_record_t *record = sdp_record_alloc();
// set the general service ID
sdp_uuid128_create( &svc_uuid, &service_uuid_int );
sdp_set_service_id( &record, svc_uuid );
// 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 );
// 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 );
// set rfcomm information
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 );
// attach protocol information to service record
access_proto_list = sdp_list_append( 0, proto_list );
sdp_set_access_protos( record, access_proto_list );
// set the name, provider, and description
sdp_set_info_attr(record, service_name, service_prov, service_dsc);
int err = 0;
sdp_session_t *session = 0;
// connect to the local SDP server,
// register the service record, and
// disconnect
session = sdp_connect( BDADDR_ANY, BDADDR_LOCAL,
SDP_RETRY_IF_BUSY );
err = sdp_record_register(session, record, 0); // FAILS
// 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 );
return session;
}
- Previous message: [maemo-developers] Laika 2.0 released
- Next message: [maemo-developers] Registering bluetooth service
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
