Service Discovery Protocol (SDP)

group sdp

The Service Discovery Protocol (SDP) allows a device to discover services offered by other devices, and their associated parameters.

For example, when you use a mobile phone with a Bluetooth headset, the phone uses SDP to determine which Bluetooth profiles the headset can use (Headset Profile, Hands Free Profile, Advanced Audio Distribution Profile (A2DP) etc.) and the protocol multiplexer settings needed for the phone to connect to the headset using each of them. Each service is identified by a Universally Unique Identifier (UUID), with official services (Bluetooth profiles) assigned a short form UUID (16 bits rather than the full 128).

Defines

SDP_PSM

Define the PSM that SDP uses.

SDP_DISC_ATTR_LEN_MASK

Masks for attr_value field of wiced_bt_sdp_discovery_attribute_t.

SDP_DISC_ATTR_TYPE(len_type)

Masks for attr_len_type field of wiced_bt_sdp_discovery_attribute_t.

SDP_DISC_ATTR_LEN(len_type)

Masks for attr_len.

SDP_MAX_LIST_ELEMS

Maximum number of protocol list items (list_elem in wiced_bt_sdp_protocol_elem_t)

SDP_MAX_UUID_FILTERS

SDP Max UUID filters.

num_uuid field of wiced_bt_sdp_init_discovery_db API should be less than SDP_MAX_UUID_FILTERS

SDP_MAX_ATTR_FILTERS

SDP Max Attribute filters.

num_attr field of wiced_bt_sdp_init_discovery_db API should be less than SDP_MAX_ATTR_FILTERS

SDP_MAX_PROTOCOL_PARAMS

SDP Max Protocol Parameters.

num_params field in wiced_bt_sdp_protocol_elem_t structure

SDP_UINT1(value)

SDP attribute 1 byte.

SDP_UINT2(value)

SDP attribute 2 byte.

SDP_UINT4(value)

SDP attribute 4 byte.

SDP_UINT8(value)

SDP attribute 8 byte.

SDP_BOOLEAN

SDP attribute BOOLEAN type.

SDP_ATTR_VALUE_UINT1(value)

SDP attribute value UINT 1 byte.

SDP_ATTR_VALUE_UINT2(value)

SDP attribute value UINT 2 byte.

SDP_ATTR_VALUE_UINT4(value)

SDP attribute value UINT 4 byte.

SDP_ATTR_VALUE_UINT8(value)

SDP attribute value UINT 8 byte.

SDP_ATTR_VALUE_BOOLEAN(value)

SDP attribute value BOOLEAN type.

SDP_ATTR_VALUE_TEXT

SDP attribute value text.

SDP_ATTR_VALUE_TEXT_1(len)

SDP attribute value text 1 byte.

SDP_ATTR_VALUE_TEXT_2(len)

SDP attribute value text 2 byte.

SDP_ATTR_VALUE_TEXT_4(len)

SDP attribute value text 4 byte.

SDP_ATTR_UINT1(id, value)

SDP attribute id with 1 byte value.

SDP_ATTR_UINT2(id, value)

SDP attribute id with 2 byte value.

SDP_ATTR_UINT4(id, value)

SDP attribute id with 4 byte value.

SDP_ATTR_UINT8(id, value)

SDP attribute id with 8 byte value.

SDP_ATTR_BOOLEAN(id, value)

SDP attribute id with BOOLEAN value.

SDP_ATTR_ID

SDP attribute id.

SDP_ATTR_UUID16(uuid)

SDP attribute 16 bit UUID.

SDP_ATTR_TEXT(id, len)

SDP attribute id with text.

SDP_ATTR_TEXT_1(id, len)

SDP attribute id with 1 byte text value.

SDP_ATTR_TEXT_2(id, len)

SDP attribute id with 2 byte text value.

SDP_ATTR_TEXT_4(id, len)

SDP attribute id with 4 byte text value.

SDP_ATTR_SEQUENCE_1(length)

SDP attribute Sequence 1 byte.

SDP_ATTR_SEQUENCE_2(length)

SDP attribute Sequence 2 byte.

SDP_ATTR_SEQUENCE_4(length)

SDP attribute Sequence 4 byte.

SDP_ATTR_RECORD_HANDLE(handle)

Service Record Handle 0x0000.

SDP_ATTR_CLASS_ID(uuid)

Service Class ID List 0x0001.

SDP_ATTR_SERVICE_RECORD_STATE(state)

Service Record State 0x0002.

SDP_ATTR_SERVICE_ID(uuid)

Service ID 0x0003.

SDP_ATTR_PROTOCOL_DESC_LIST(l2cap_chan)

Protocol Descriptor List 0x0004 for L2CAP.

SDP_ATTR_SDP_PROTOCOL_DESC_LIST(l2cap_chan)

Protocol Descriptor List 0x0004 for SDP.

SDP_ATTR_HIDP_PROTOCOL_DESC_LIST(l2cap_chan)

Protocol Descriptor List 0x0004 for HIDP.

SDP_ATTR_RFCOMM_PROTOCOL_DESC_LIST(scn)

Protocol Descriptor List 0x0004 for RFCOMM.

SDP_ATTR_BROWSE_LIST

Browse Group List 0x0005.

SDP_ATTR_LANGUAGE_BASE_ATTR_ID_LIST

Language Base 0x0006.

SDP_ATTR_SERVICE_INFO_TIME_TO_LIVE(seconds)

Service Info Time to Live 0x0007.

SDP_ATTR_SERVICE_AVAILABILITY(availability)

Service Availability 0x0008.

SDP_ATTR_PROFILE_DESC_LIST(uuid, version)

BT Profile Descriptor List 0x0009.

SDP_ATTR_DOCUMENTATION_URL(len)

Documentation URL 0x000A.

SDP_ATTR_CLIENT_EXECUTABLE_URL(len)

Client Executable URL 0x000B.

SDP_ATTR_ICON_URL(len)

Icon URL 0x000C.

SDP_ATTR_SERVICE_NAME(len)

Service Name LANGUAGE_BASE_ID (0x0100) + 0x0000 = 0x0100.

SDP_ATTR_SERVICE_DESCRIPTION(len)

Service Description LANGUAGE_BASE_ID (0x0100) + 0x0001 = 0x0101.

SDP_ATTR_PROVIDER_NAME(len)

Provider Name LANGUAGE_BASE_ID (0x0100) + 0x0002 = 0x0102.

SDP_ATTR_GROUP_ID(uuid)

Group ID 0x0200.

SDP_ATTR_VERSION_NUMBER_LIST(version)

Version Number List 0x0200.

SDP_ATTR_SERVICE_DATABASE_STATE(state)

Service Database State 0x0201.

Typedefs

void() wiced_bt_sdp_discovery_complete_cback_t (uint16_t sdp_result)

Service discovery complete callback.

If discovery was successful, the discovery results database (provided when wiced_bt_sdp_service_search_request or wiced_bt_sdp_service_search_attribute_request was called) will be filled.

Use the wiced_bt_sdp_find_* utility functions to parse the results.

Parameters

sdp_result[in] : SDP result code (see wiced_bt_sdp_result_t )

Returns

Nothing

Enums

enum wiced_bt_sdp_result_t

wiced_bt_sdp_result_t: SDP result - Success code and error codes.

Values:

enumerator WICED_BT_SDP_SUCCESS

SDP - Result: Success.

enumerator WICED_BT_SDP_INVALID_VERSION

SDP - invalid version.

enumerator WICED_BT_SDP_INVALID_SERV_REC_HDL

SDP - invalid service record.

enumerator WICED_BT_SDP_INVALID_REQ_SYNTAX

SDP - invalid request syntax.

enumerator WICED_BT_SDP_INVALID_PDU_SIZE

SDP - invalid PDU size.

enumerator WICED_BT_SDP_INVALID_CONT_STATE

SDP - invalid controller state.

enumerator WICED_BT_SDP_NO_RESOURCES

SDP - no resources.

enumerator WICED_BT_SDP_DI_REG_FAILED

SDP - registration failed.

enumerator WICED_BT_SDP_DI_DISC_FAILED

SDP - discovery failed.

enumerator WICED_BT_SDP_NO_DI_RECORD_FOUND

SDP - no record found.

enumerator WICED_BT_SDP_ERR_ATTR_NOT_PRESENT

SDP - no attribute present.

enumerator WICED_BT_SDP_ILLEGAL_PARAMETER

SDP - Illegal parameter.

enumerator WICED_BT_SDP_NO_RECS_MATCH

SDP - No records match.

enumerator WICED_BT_SDP_CONN_FAILED

SDP - Connection failed.

enumerator WICED_BT_SDP_CFG_FAILED

SDP - Configuration failed.

enumerator WICED_BT_SDP_GENERIC_ERROR

SDP - Generic error.

enumerator WICED_BT_SDP_DB_FULL

SDP - DB full.

enumerator WICED_BT_SDP_INVALID_PDU

SDP - Invalid PDU.

enumerator WICED_BT_SDP_SECURITY_ERR

SDP - Security Error.

enumerator WICED_BT_SDP_CONN_REJECTED

SDP - Connection rejected.

enumerator WICED_BT_SDP_CANCEL

SDP - cancel.

Functions

wiced_bool_t wiced_bt_sdp_db_init(const uint8_t *p_sdp_db, uint16_t size)

Initialize local SDP server database (database generated using WICED BT Designer)

Parameters
  • p_sdp_db[in] First element in database array

  • size[in] size (in bytes) of SDP database

Returns

TRUE if successful, FALSE otherwise

wiced_bool_t wiced_bt_sdp_init_discovery_db(wiced_bt_sdp_discovery_db_t *p_db, uint32_t len, uint16_t num_uuid, wiced_bt_uuid_t *p_uuid_list, uint16_t num_attr, uint16_t *p_attr_list)

Initialize discovery database prior to performing service discovery (using wiced_bt_sdp_service_search_request or wiced_bt_sdp_service_search_request ).

Provides a list of UUIDs and/or attribute IDs to search for.

Parameters
  • p_db[in] : Discovery database to initialize

  • len[in] : size of discovery database

  • num_uuid[in] : Number of UUIDs in p_uuid_list

  • p_uuid_list[in] : UUIDs to add to discovery database

  • num_attr[in] : Number of attributes in p_attr_list

  • p_attr_list[in] : Attributes to add to discovery database

Returns

TRUE if successful, FALSE if one or more parameters are bad

wiced_bool_t wiced_bt_sdp_cancel_service_search(wiced_bt_sdp_discovery_db_t *p_db)

Cancel service search request.

Parameters

p_db[in] : Discovery database of the request being cancelled

Returns

TRUE if discovery cancelled, FALSE if a matching activity is not found.

wiced_bool_t wiced_bt_sdp_service_search_request(uint8_t *p_bd_addr, wiced_bt_sdp_discovery_db_t *p_db, wiced_bt_sdp_discovery_complete_cback_t *p_cb)

Initiate service search on remote device.

Parameters
  • p_bd_addr[in] : Remote device address

  • p_db[in] : Discovery database of UUIDs and attribute IDs to search for (intialized using wiced_bt_sdp_init_discovery_db )

  • p_cb[in] : Callback for discovery results

Returns

TRUE if discovery started, FALSE if failed.

wiced_bool_t wiced_bt_sdp_service_search_attribute_request(uint8_t *p_bd_addr, wiced_bt_sdp_discovery_db_t *p_db, wiced_bt_sdp_discovery_complete_cback_t *p_cb)

Initiate combined service search and attribute request on remote device.

Parameters
  • p_bd_addr[in] : Remote device address

  • p_db[in] : Discovery database of UUIDs and attribute IDs to search for (intialized using wiced_bt_sdp_init_discovery_db )

  • p_cb[in] : Callback for discovery results

Returns

TRUE if discovery started, FALSE if failed.

wiced_bt_sdp_discovery_record_t *wiced_bt_sdp_find_attribute_in_db(wiced_bt_sdp_discovery_db_t *p_db, uint16_t attr_id, wiced_bt_sdp_discovery_record_t *p_start_rec)

Parse results from service search.

Look next record in discovery database containing attribute ID.

Parameters
  • p_db[in] : Discovery results database

  • attr_id[in] : Attribute ID to find

  • p_start_rec[in] : Starting record to search from (if NULL, start from beginning of database)

Returns

Pointer to matching record, or NULL

wiced_bt_sdp_discovery_attribute_t *wiced_bt_sdp_find_attribute_in_rec(wiced_bt_sdp_discovery_record_t *p_rec, uint16_t attr_id)

Parse SDP record.

Look for requested attribute in the service record.

Parameters
  • p_rec[in] : Service record

  • attr_id[in] : Attribute ID to find

Returns

Pointer to matching attribute entry, or NULL

wiced_bt_sdp_discovery_record_t *wiced_bt_sdp_find_service_in_db(wiced_bt_sdp_discovery_db_t *p_db, uint16_t service_uuid, wiced_bt_sdp_discovery_record_t *p_start_rec)

Parse results from service search.

Look next record in discovery database containing requested service UUID (specified using uint16_t)

Parameters
  • p_db[in] : Discovery results database

  • service_uuid[in] Service to find

  • p_start_rec[in] : Starting record to search from (if NULL, start from beginning of database)

Returns

Pointer to matching record, or NULL

wiced_bt_sdp_discovery_record_t *wiced_bt_sdp_find_service_uuid_in_db(wiced_bt_sdp_discovery_db_t *p_db, wiced_bt_uuid_t *p_uuid, wiced_bt_sdp_discovery_record_t *p_start_rec)

Parse results from service search.

Look next record in discovery database containing requested service UUID (specified using wiced_bt_uuid_t structure)

Parameters
  • p_db[in] : Discovery results database

  • p_uuid[in] : Service to find

  • p_start_rec[in] : Starting record to search from (if NULL, start from beginning of database)

Returns

Pointer to matching record, or NULL

wiced_bool_t wiced_bt_sdp_find_protocol_list_elem_in_rec(wiced_bt_sdp_discovery_record_t *p_rec, uint16_t layer_uuid, wiced_bt_sdp_protocol_elem_t *p_elem)

Parse SDP record.

Look for requested protocol list element in the service record.

Parameters
  • p_rec[in] : Service record

  • layer_uuid[in] : protocol list element to find

  • p_elem[out] : protocol list element (if found)

Returns

TRUE if found, else FALSE

wiced_bool_t wiced_bt_sdp_find_protocol_lists_elem_in_rec(wiced_bt_sdp_discovery_record_t *p_rec, uint16_t layer_uuid, wiced_bt_sdp_protocol_elem_t *p_elem)

Parse SDP record.

Look for requested protocol lists element in the service record.

Parameters
  • p_rec[in] : Service record

  • layer_uuid[in] : protocol lists element to find

  • p_elem[out] : protocol lists element (if found)

Returns

TRUE if found, else FALSE

wiced_bool_t wiced_bt_sdp_find_profile_version_in_rec(wiced_bt_sdp_discovery_record_t *p_rec, uint16_t profile_uuid, uint16_t *p_version)

Parse SDP record.

Look for version of requested profile.

Parameters
  • p_rec[in] : Service record

  • profile_uuid[in] Profile to find

  • p_version[out] : Major/minor version of profile (if found)

Returns

TRUE if found, FALSE if not

wiced_bool_t wiced_bt_sdp_find_service_uuid_in_rec(wiced_bt_sdp_discovery_record_t *p_rec, wiced_bt_uuid_t *p_uuid)

Parse SDP record.

Look for service UUID

Parameters
  • p_rec[in] : Service record

  • p_uuid[out] : Service UUID of the record

Returns

TRUE if found, FALSE if not

struct wiced_bt_sdp_discovery_attribute_value_t
#include <>

Attribute value.

Public Members

uint8_t u8

8-bit integer

uint16_t u16

16-bit integer

uint32_t u32

32-bit integer

uint8_t array[4]

Variable length field.

struct t_sdp_discovery_attr *p_sub_attr

Addr of first sub-attr (list)

union wiced_bt_sdp_discovery_attribute_value_t::[anonymous] v

Attribute value union.

struct wiced_bt_sdp_discovery_attribute_t
#include <>

SDP Attribute.

Public Members

struct t_sdp_discovery_attr *p_next_attr

Addr of next linked attr.

uint16_t attr_id

Attribute ID.

uint16_t attr_len_type

Length and type fields.

wiced_bt_sdp_discovery_attribute_value_t attr_value

Variable length entry data.

struct wiced_bt_sdp_discovery_record_t
#include <>

Discovery record from SDP search result.

Public Members

wiced_bt_sdp_discovery_attribute_t *p_first_attr

First attribute of record.

struct sdp_discovery_record_t *p_next_rec

Addr of next linked record.

uint32_t time_read

The time the record was read.

struct wiced_bt_sdp_discovery_db_t
#include <>

Discovery database (used for performing service searches and holding search results)

Public Members

uint32_t mem_size

Memory size of the DB.

uint32_t mem_free

Memory still available.

wiced_bt_sdp_discovery_record_t *p_first_rec

Addr of first record in DB.

uint16_t num_uuid_filters

Number of UUIds to filter.

wiced_bt_uuid_t uid_filters[SDP_MAX_UUID_FILTERS]

UUIDs to filter.

uint16_t num_attr_filters

Number of attribute filters.

uint16_t attr_filters[SDP_MAX_ATTR_FILTERS]

Attributes to filter.

uint8_t *p_free_mem

Pointer to free memory.

struct wiced_bt_sdp_protocol_elem_t
#include <>

This structure is used to add protocol lists and find protocol elements.

Public Members

uint16_t protocol_uuid

The protocol uuid.

uint16_t num_params

Number of parameters.

uint16_t params[SDP_MAX_PROTOCOL_PARAMS]

Contents of protocol parameters.