dotstack API Reference  1.10.37
Modules | Macros | Functions
SDP

This module describe functions and data structures used to start the SDP server and perform SDP queries. More...

Modules

 Configuration
 This module describes parameters used to configure SDP.
 

Macros

#define BEGIN_DE_SEQUENCE_SEQ(id)   seq_##id
 Begin a data element sequence. More...
 
#define END_DE_SEQUENCE(id)   }}
 End a data element sequence. More...
 
#define INIT_DE_SEQUENCE(id)   init_de_sequence_##id();
 Initialize a data element sequence. More...
 
#define DE_UINT(value)   cur_de->type = SDP_DATA_TYPE_UINT; cur_de->data.b = value; cur_de++; if (++i == max_len) return;
 Declare a 1-byte unsigned integer data element. More...
 
#define DE_UINT16(value)   cur_de->type = SDP_DATA_TYPE_UINT16; cur_de->data.ui = value; cur_de++; if (++i == max_len) return;
 Declare a 2-byte unsigned integer data element. More...
 
#define DE_UINT32(value)   cur_de->type = SDP_DATA_TYPE_UINT32; cur_de->data.ul = value; cur_de++; if (++i == max_len) return;
 Declare a 4-byte unsigned integer data element. More...
 
#define DE_INT(value)   cur_de->type = SDP_DATA_TYPE_INT; cur_de->data.b = value; cur_de++; if (++i == max_len) return;
 Declare a 1-byte signed integer data element. More...
 
#define DE_STRING(value)   cur_de->type = SDP_DATA_TYPE_STRING; cur_de->data.pstr = value; cur_de++;
 Declare a text string data element. More...
 
#define DE_STRING2(value, len)   cur_de->type = SDP_DATA_TYPE_UINT; cur_de->data.pstr = value; cur_de->bytecount = len; cur_de++; if (++i == max_len) return;
 Declare a text string data element. More...
 
#define DE_BOOL(value)   cur_de->type = SDP_DATA_TYPE_BOOL; cur_de->data.b = value; cur_de++; if (++i == max_len) return;
 Declare a boolean data element. More...
 
#define DE_UUID16(value)   cur_de->type = SDP_DATA_TYPE_UUID16; cur_de->data.uuid16 = value; cur_de++; if (++i == max_len) return;
 Declare a 16-bit UUID data element. More...
 
#define DE_UUID32(value)   cur_de->type = SDP_DATA_TYPE_UUID32; cur_de->data.uuid32 = value; cur_de++; if (++i == max_len) return;
 Declare a 32-bit UUID data element. More...
 
#define DE_UUID128(value)   cur_de->type = SDP_DATA_TYPE_UUID128; cur_de->data.uuid128 = (bt_uuid_t*)&value; cur_de++; if (++i == max_len) return;
 Declare a 128-bit UUID data element. More...
 
#define DE_URL(value)   cur_de->type = SDP_DATA_TYPE_URL; cur_de->data.purl = value; cur_de++; if (++i == max_len) return;
 Declare a URL data element. More...
 

Functions

bt_bool bt_sdp_start (bt_l2cap_mgr_t *l2cap_mgr, const bt_byte *sdp_db, bt_uint sdp_db_len)
 Start SDP server. More...
 
bt_bool bt_sdp_request_service_search (bt_l2cap_channel_t *channel, bt_sdp_data_element_p pattern, bt_sdp_service_search_callback_fp callback, void *callback_param)
 Search service records. More...
 
bt_bool bt_sdp_request_service_attribute (bt_l2cap_channel_t *channel, bt_sr_handle_t sr, bt_sdp_data_element_p pattern, bt_sdp_service_attribute_callback_fp callback, void *callback_param)
 Search attributes. More...
 

Detailed Description

This module describe functions and data structures used to start the SDP server and perform SDP queries.

Macro Definition Documentation

#define BEGIN_DE_SEQUENCE_SEQ (   id)    seq_##id

Begin a data element sequence.

BEGIN_DE_SEQUENCE and END_DE_SEQUENCE are used to define a data element sequence which is an array of sdp_data_element structures. The array is used a search pattern in bt_sdp_request_service_search() and bt_sdp_request_service_attribute(). For example, to find a AVRCP Target the following code can be used:

1 const bt_uuid_t AVRCP_AV_REMOTE_CONTROL_CLSID = { 0x5F9B34FB, 0x80000080, 0x00001000, SDP_CLSID_AV_REMOTE_CONTROL };
2 const bt_uuid_t AVRCP_AV_REMOTE_CONTROL_TARGET_CLSID = { 0x5F9B34FB, 0x80000080, 0x00001000, SDP_CLSID_AV_REMOTE_CONTROL_TARGET };
3 
4 BEGIN_DE_SEQUENCE(avrcp_target_service_search, 2)
5  DE_UUID128(AVRCP_AV_REMOTE_CONTROL_CLSID)
6  DE_UUID128(AVRCP_AV_REMOTE_CONTROL_TARGET_CLSID)
7 END_DE_SEQUENCE(avrcp_target_service_search)
8 
9 .
10 .
11 .
12 
13 void findAvrcpTarget(void)
14 {
15  INIT_DE_SEQUENCE(avrcp_target_service_search);
16 
17  bt_sdp_request_service_search(channel, &seq_avrcp_target_service_search, &callback, NULL);
18 }
Parameters
idThe data element sequence identifier.
lenThe number of elements in the data element sequence.
#define DE_BOOL (   value)    cur_de->type = SDP_DATA_TYPE_BOOL; cur_de->data.b = value; cur_de++; if (++i == max_len) return;

Declare a boolean data element.

This macro adds a boolean data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_INT (   value)    cur_de->type = SDP_DATA_TYPE_INT; cur_de->data.b = value; cur_de++; if (++i == max_len) return;

Declare a 1-byte signed integer data element.

This macro adds a 1-byte signed integer data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_STRING (   value)    cur_de->type = SDP_DATA_TYPE_STRING; cur_de->data.pstr = value; cur_de++;

Declare a text string data element.

This macro adds a text string data element to a data element sequence. The length of the generated data element will be the actual length of the string. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_STRING2 (   value,
  len 
)    cur_de->type = SDP_DATA_TYPE_UINT; cur_de->data.pstr = value; cur_de->bytecount = len; cur_de++; if (++i == max_len) return;

Declare a text string data element.

This macro adds a text string data element to a data element sequence. The length of the generated data element will be the value specified by the "len" parameter even if the actual length of the string is not equal to the "len" value. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
lenThe length of the data element value.
#define DE_UINT (   value)    cur_de->type = SDP_DATA_TYPE_UINT; cur_de->data.b = value; cur_de++; if (++i == max_len) return;

Declare a 1-byte unsigned integer data element.

This macro adds a 1-byte unsigned integer data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_UINT16 (   value)    cur_de->type = SDP_DATA_TYPE_UINT16; cur_de->data.ui = value; cur_de++; if (++i == max_len) return;

Declare a 2-byte unsigned integer data element.

This macro adds a 2-byte unsigned integer data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_UINT32 (   value)    cur_de->type = SDP_DATA_TYPE_UINT32; cur_de->data.ul = value; cur_de++; if (++i == max_len) return;

Declare a 4-byte unsigned integer data element.

This macro adds a 4-byte unsigned integer data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_URL (   value)    cur_de->type = SDP_DATA_TYPE_URL; cur_de->data.purl = value; cur_de++; if (++i == max_len) return;

Declare a URL data element.

This macro adds a URL data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value which is a pointer to a string.
#define DE_UUID128 (   value)    cur_de->type = SDP_DATA_TYPE_UUID128; cur_de->data.uuid128 = (bt_uuid_t*)&value; cur_de++; if (++i == max_len) return;

Declare a 128-bit UUID data element.

This macro adds a 128-bit UUID data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value. The value must be a name of a variable of type bt_uuid.
#define DE_UUID16 (   value)    cur_de->type = SDP_DATA_TYPE_UUID16; cur_de->data.uuid16 = value; cur_de++; if (++i == max_len) return;

Declare a 16-bit UUID data element.

This macro adds a 16-bit UUID data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define DE_UUID32 (   value)    cur_de->type = SDP_DATA_TYPE_UUID32; cur_de->data.uuid32 = value; cur_de++; if (++i == max_len) return;

Declare a 32-bit UUID data element.

This macro adds a 32-bit UUID data element to a data element sequence. This macro is to be used between BEGIN_DE_SEQUENCE and END_DE_SEQUENCE.

Parameters
valueThe data element value.
#define END_DE_SEQUENCE (   id)    }}

End a data element sequence.

BEGIN_DE_SEQUENCE and END_DE_SEQUENCE are used to define a data element sequence which is an array of bt_sdp_data_element structures.

Parameters
idThe data element sequence identifier.
#define INIT_DE_SEQUENCE (   id)    init_de_sequence_##id();

Initialize a data element sequence.

This macro calls a function defined in BEGIN_DE_SEQUENCE which initializes the data element sequence.

Parameters
idThe data element sequence identifier.

Function Documentation

bt_bool bt_sdp_request_service_attribute ( bt_l2cap_channel_t *  channel,
bt_sr_handle_t  sr,
bt_sdp_data_element_p  pattern,
bt_sdp_service_attribute_callback_fp  callback,
void *  callback_param 
)

Search attributes.

This function retrieves attribute values from a service record.

Parameters
channelThe L2CAP channel used to communicate to the remote SDP server.
srThe service record handle specifies the service record from which attribute values are to be retrieved.
patternThe attribute search pattern is a data element sequence where each element in the list is either an attribute ID or a range of attribute IDs. The pattern buffer must be valid for the duration of the search operation, i.e. until callback is called for the first time. To define a data element sequence use the BEGIN_DE_SEQUENCE and END_DE_SEQUENCE macros. These macros will define a variable whose name is the id of the data element sequence passed to the macros prefixed with "seq_". A pointer to this variable can be used as the value for the pattern parameter.
callbackThe callback function that will be called when search has completed.
callback_paramA pointer to arbitrary data to be passed to the callback callback.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. The callback function is not called in this case.
bt_bool bt_sdp_request_service_search ( bt_l2cap_channel_t *  channel,
bt_sdp_data_element_p  pattern,
bt_sdp_service_search_callback_fp  callback,
void *  callback_param 
)

Search service records.

This function locates service records on a remote SDP server that match the given service search pattern.

Parameters
channelThe L2CAP channel used to communicate to the remote SDP server.
patternThe service search pattern is a data element sequence where each element in the sequence is a UUID. The sequence must contain at least one UUID. The maximum number of UUIDs in the sequence is 12. The pattern buffer must be valid for the duration of the search operation, i.e. until callback is called. To define a data element sequence use the BEGIN_DE_SEQUENCE and END_DE_SEQUENCE macros. These macros will define a variable whose name is the id of the data element sequence passed to the macros prefixed with "seq_". A pointer to this variable can be used as the value for the pattern parameter.
callbackThe callback function that will be called when search has completed.
callback_paramA pointer to arbitrary data to be passed to the callback callback.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise. The callback function is not called in this case.
bt_bool bt_sdp_start ( bt_l2cap_mgr_t l2cap_mgr,
const bt_byte *  sdp_db,
bt_uint  sdp_db_len 
)

Start SDP server.

This function starts the SDP server.

Parameters
l2cap_mgrThe L2CAP manager on which the SDP server is to be started.
sdp_dbA pointer to the SDP database define with BEGIN_SDP_DB and END_SDP_DB macros.
Returns
  • TRUE if the function succeeds.
  • FALSE otherwise.