Service Discovery Protocol (SDP)

API Reference

group bt_sdp

Service Discovery Protocol (SDP)

Defines

BT_SDP_SDP_SERVER_SVCLASS
BT_SDP_BROWSE_GRP_DESC_SVCLASS
BT_SDP_PUBLIC_BROWSE_GROUP
BT_SDP_SERIAL_PORT_SVCLASS
BT_SDP_LAN_ACCESS_SVCLASS
BT_SDP_DIALUP_NET_SVCLASS
BT_SDP_IRMC_SYNC_SVCLASS
BT_SDP_OBEX_OBJPUSH_SVCLASS
BT_SDP_OBEX_FILETRANS_SVCLASS
BT_SDP_IRMC_SYNC_CMD_SVCLASS
BT_SDP_HEADSET_SVCLASS
BT_SDP_CORDLESS_TELEPHONY_SVCLASS
BT_SDP_AUDIO_SOURCE_SVCLASS
BT_SDP_AUDIO_SINK_SVCLASS
BT_SDP_AV_REMOTE_TARGET_SVCLASS
BT_SDP_ADVANCED_AUDIO_SVCLASS
BT_SDP_AV_REMOTE_SVCLASS
BT_SDP_AV_REMOTE_CONTROLLER_SVCLASS
BT_SDP_INTERCOM_SVCLASS
BT_SDP_FAX_SVCLASS
BT_SDP_HEADSET_AGW_SVCLASS
BT_SDP_WAP_SVCLASS
BT_SDP_WAP_CLIENT_SVCLASS
BT_SDP_PANU_SVCLASS
BT_SDP_NAP_SVCLASS
BT_SDP_GN_SVCLASS
BT_SDP_DIRECT_PRINTING_SVCLASS
BT_SDP_REFERENCE_PRINTING_SVCLASS
BT_SDP_IMAGING_SVCLASS
BT_SDP_IMAGING_RESPONDER_SVCLASS
BT_SDP_IMAGING_ARCHIVE_SVCLASS
BT_SDP_IMAGING_REFOBJS_SVCLASS
BT_SDP_HANDSFREE_SVCLASS
BT_SDP_HANDSFREE_AGW_SVCLASS
BT_SDP_DIRECT_PRT_REFOBJS_SVCLASS
BT_SDP_REFLECTED_UI_SVCLASS
BT_SDP_BASIC_PRINTING_SVCLASS
BT_SDP_PRINTING_STATUS_SVCLASS
BT_SDP_HID_SVCLASS
BT_SDP_HCR_SVCLASS
BT_SDP_HCR_PRIN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T_SDP_ATTR_SVCINFO_TTL
BT_SDP_ATTR_SERVICE_AVAILABILITY
BT_SDP_ATTR_PROFILE_DESC_LIST
BT_SDP_ATTR_DOC_URL
BT_SDP_ATTR_CLNT_EXEC_URL
BT_SDP_ATTR_ICON_URL
BT_SDP_ATTR_ADD_PROTO_DESC_LIST
BT_SDP_ATTR_GROUP_ID
BT_SDP_ATTR_IP_SUBNET
BT_SDP_ATTR_VERSION_NUM_LIST
BT_SDP_ATTR_SUPPORTED_FEATURES_LIST
BT_SDP_ATTR_GOEP_L2CAP_PSM
BT_SDP_ATTR_SVCDB_STATE
BT_SDP_ATTR_MPSD_SCENARIOS
BT_SDP_ATTR_MPMD_SCENARIOS
BT_SDP_ATTR_MPS_DEPENDENCIES
BT_SDP_ATTR_SERVICE_VERSION
BT_SDP_ATTR_EXTERNAL_NETWORK
BT_SDP_ATTR_SUPPORTED_DATA_STORES_LIST
BT_SDP_ATTR_DATA_EXCHANGE_SPEC
BT_SDP_ATTR_NETWORK
BT_SDP_ATTR_FAX_CLASS1_SUPPORT
BT_SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL
BT_SDP_ATTR_MCAP_SUPPORTED_PROCEDURES
BT_SDP_ATTR_FAX_CLASS20_SUPPORT
BT_SDP_ATTR_SUPPORTED_FORMATS_LIST
BT_SDP_ATTR_FAX_CLASS2_SUPPORT
BT_SDP_ATTR_AUDIO_FEEDBACK_SUPPORT
BT_SDP_ATTR_NETWORK_ADDRESS
BT_SDP_ATTR_WAP_GATEWAY
BT_SDP_ATTR_HOMEPAGE_URL
BT_SDP_ATTR_WAP_STACK_TYPE
BT_SDP_ATTR_SECURITY_DESC
BT_SDP_ATTR_NET_ACCESS_TYPE
BT_SDP_ATTR_MAX_NET_ACCESSRATE
BT_SDP_ATTR_IP4_SUBNET
BT_SDP_ATTR_IP6_SUBNET
BT_SDP_ATTR_SUPPORTED_CAPABILITIES
BT_SDP_ATTR_SUPPORTED_FEATURES
BT_SDP_ATTR_SUPPORTED_FUNCTIONS
BT_SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY
BT_SDP_ATTR_SUPPORTED_REPOSITORIES
BT_SDP_ATTR_MAS_INSTANCE_ID
BT_SDP_ATTR_SUPPORTED_MESSAGE_TYPES
BT_SDP_ATTR_PBAP_SUPPORTED_FEATURES
BT_SDP_ATTR_MAP_SUPPORTED_FEATURES
BT_SDP_ATTR_SPECIFICATION_ID
BT_SDP_ATTR_VENDOR_ID
BT_SDP_ATTR_PRODUCT_ID
BT_SDP_ATTR_VERSION
BT_SDP_ATTR_PRIMARY_RECORD
BT_SDP_ATTR_VENDOR_ID_SOURCE
BT_SDP_ATTR_HID_DEVICE_RELEASE_NUMBER
BT_SDP_ATTR_HID_PARSER_VERSION
BT_SDP_ATTR_HID_DEVICE_SUBCLASS
BT_SDP_ATTR_HID_COUNTRY_CODE
BT_SDP_ATTR_HID_VIRTUAL_CABLE
BT_SDP_ATTR_HID_RECONNECT_INITIATE
BT_SDP_ATTR_HID_DESCRIPTOR_LIST
BT_SDP_ATTR_HID_LANG_ID_BASE_LIST
BT_SDP_ATTR_HID_SDP_DISABLE
BT_SDP_ATTR_HID_BATTERY_POWER
BT_SDP_ATTR_HID_REMOTE_WAKEUP
BT_SDP_ATTR_HID_PROFILE_VERSION
BT_SDP_ATTR_HID_SUPERVISION_TIMEOUT
BT_SDP_ATTR_HID_NORMALLY_CONNECTABLE
BT_SDP_ATTR_HID_BOOT_DEVICE
BT_SDP_PRIMARY_LANG_BASE
BT_SDP_ATTR_SVCNAME_PRIMARY
BT_SDP_ATTR_SVCDESC_PRIMARY
BT_SDP_ATTR_PROVNAME_PRIMARY
BT_SDP_DATA_NIL
BT_SDP_UINT8
BT_SDP_UINT16
BT_SDP_UINT32
BT_SDP_UINT64
BT_SDP_UINT128
BT_SDP_INT8
BT_SDP_INT16
BT_SDP_INT32
BT_SDP_INT64
BT_SDP_INT128
BT_SDP_UUID_UNSPEC
BT_SDP_UUID16
BT_SDP_UUID32
BT_SDP_UUID128
BT_SDP_TEXT_STR_UNSPEC
BT_SDP_TEXT_STR8
BT_SDP_TEXT_STR16
BT_SDP_TEXT_STR32
BT_SDP_BOOL
BT_SDP_SEQ_UNSPEC
BT_SDP_SEQ8
BT_SDP_SEQ16
BT_SDP_SEQ32
BT_SDP_ALT_UNSPEC
BT_SDP_ALT8
BT_SDP_ALT16
BT_SDP_ALT32
BT_SDP_URL_STR_UNSPEC
BT_SDP_URL_STR8
BT_SDP_URL_STR16
BT_SDP_URL_STR32
BT_SDP_TYPE_DESC_MASK
BT_SDP_SIZE_DESC_MASK
BT_SDP_SIZE_INDEX_OFFSET
BT_SDP_ARRAY_8(...)

Declare an array of 8-bit elements in an attribute.

BT_SDP_ARRAY_16(...)

Declare an array of 16-bit elements in an attribute.

BT_SDP_ARRAY_32(...)

Declare an array of 32-bit elements in an attribute.

BT_SDP_TYPE_SIZE(_type)

Declare a fixed-size data element header.

Parameters
  • _type – Data element header containing type and size descriptors.

BT_SDP_TYPE_SIZE_VAR(_type, _size)

Declare a variable-size data element header.

Parameters
  • _type – Data element header containing type and size descriptors.

  • _size – The actual size of the data.

BT_SDP_DATA_ELEM_LIST(...)

Declare a list of data elements.

BT_SDP_NEW_SERVICE

SDP New Service Record Declaration Macro.

Helper macro to declare a new service record. Default attributes: Record Handle, Record State, Language Base, Root Browse Group

BT_SDP_LIST(_att_id, _type_size, _data_elem_seq)

Generic SDP List Attribute Declaration Macro.

Helper macro to declare a list attribute.

Parameters
  • _att_id – List Attribute ID.

  • _data_elem_seq – Data element sequence for the list.

  • _type_size – SDP type and size descriptor.

BT_SDP_SERVICE_ID(_uuid)

SDP Service ID Attribute Declaration Macro.

Helper macro to declare a service ID attribute.

Parameters
  • _uuid – Service ID 16bit UUID.

BT_SDP_SERVICE_NAME(_name)

SDP Name Attribute Declaration Macro.

Helper macro to declare a service name attribute.

Parameters
  • _name – Service name as a string (up to 256 chars).

BT_SDP_SUPPORTED_FEATURES(_features)

SDP Supported Features Attribute Declaration Macro.

Helper macro to declare supported features of a profile/protocol.

Parameters
  • _features – Feature mask as 16bit unsigned integer.

BT_SDP_RECORD(_attrs)

SDP Service Declaration Macro.

Helper macro to declare a service.

Parameters
  • _attrs – List of attributes for the service record.

Typedefs

typedef uint8_t (*bt_sdp_discover_func_t)(struct bt_conn *conn, struct bt_sdp_client_result *result)

Callback type reporting to user that there is a resolved result on remote for given UUID and the result record buffer can be used by user for further inspection.

A function of this type is given by the user to the bt_sdp_discover_params object. It’ll be called on each valid record discovery completion for given UUID. When UUID resolution gives back no records then NULL is passed to the user. Otherwise user can get valid record(s) and then the internal hint ‘next record’ is set to false saying the UUID resolution is complete or the hint can be set by caller to true meaning that next record is available for given UUID. The returned function value allows the user to control retrieving follow-up resolved records if any. If the user doesn’t want to read more resolved records for given UUID since current record data fulfills its requirements then should return BT_SDP_DISCOVER_UUID_STOP. Otherwise returned value means more subcall iterations are allowable.

Param conn

Connection object identifying connection to queried remote.

Param result

Object pointing to logical unparsed SDP record collected on base of response driven by given UUID.

Return

BT_SDP_DISCOVER_UUID_STOP in case of no more need to read next record data and continue discovery for given UUID. By returning BT_SDP_DISCOVER_UUID_CONTINUE user allows this discovery continuation.

Enums

enum [anonymous]

Helper enum to be used as return value of bt_sdp_discover_func_t. The value informs the caller to perform further pending actions or stop them.

Values:

enumerator BT_SDP_DISCOVER_UUID_STOP = 0
enumerator BT_SDP_DISCOVER_UUID_CONTINUE
enum bt_sdp_proto

Protocols to be asked about specific parameters.

Values:

enumerator BT_SDP_PROTO_RFCOMM = 0x0003
enumerator BT_SDP_PROTO_L2CAP = 0x0100

Functions

int bt_sdp_register_service(struct bt_sdp_record *service)

Register a Service Record.

Register a Service Record. Applications can make use of macros such as BT_SDP_DECLARE_SERVICE, BT_SDP_LIST, BT_SDP_SERVICE_ID, BT_SDP_SERVICE_NAME, etc. A service declaration must start with BT_SDP_NEW_SERVICE.

Parameters
  • service – Service record declared using BT_SDP_DECLARE_SERVICE.

Returns

0 in case of success or negative value in case of error.

int bt_sdp_discover(struct bt_conn *conn, const struct bt_sdp_discover_params *params)

Allows user to start SDP discovery session.

The function performs SDP service discovery on remote server driven by user delivered discovery parameters. Discovery session is made as soon as no SDP transaction is ongoing between peers and if any then this one is queued to be processed at discovery completion of previous one. On the service discovery completion the callback function will be called to get feedback to user about findings.

Parameters
  • conn – Object identifying connection to remote.

  • params – SDP discovery parameters.

Returns

0 in case of success or negative value in case of error.

int bt_sdp_discover_cancel(struct bt_conn *conn, const struct bt_sdp_discover_params *params)

Release waiting SDP discovery request.

It can cancel valid waiting SDP client request identified by SDP discovery parameters object.

Parameters
  • conn – Object identifying connection to remote.

  • params – SDP discovery parameters.

Returns

0 in case of success or negative value in case of error.

int bt_sdp_get_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto, uint16_t *param)

Give to user parameter value related to given stacked protocol UUID.

API extracts specific parameter associated with given protocol UUID available in Protocol Descriptor List attribute.

Parameters
  • buf – Original buffered raw record data.

  • proto – Known protocol to be checked like RFCOMM or L2CAP.

  • param – On success populated by found parameter value.

Returns

0 on success when specific parameter associated with given protocol value is found, or negative if error occurred during processing.

int bt_sdp_get_addl_proto_param(const struct net_buf *buf, enum bt_sdp_proto proto, uint8_t param_index, uint16_t *param)

Get additional parameter value related to given stacked protocol UUID.

API extracts specific parameter associated with given protocol UUID available in Additional Protocol Descriptor List attribute.

Parameters
  • buf – Original buffered raw record data.

  • proto – Known protocol to be checked like RFCOMM or L2CAP.

  • param_index – There may be more than one parameter realted to the given protocol UUID. This function returns the result that is indexed by this parameter. It’s value is from 0, 0 means the first matched result, 1 means the second matched result.

  • param[out] On success populated by found parameter value.

Returns

0 on success when a specific parameter associated with a given protocol value is found, or negative if error occurred during processing.

int bt_sdp_get_profile_version(const struct net_buf *buf, uint16_t profile, uint16_t *version)

Get profile version.

Helper API extracting remote profile version number. To get it proper generic profile parameter needs to be selected usually listed in SDP Interoperability Requirements section for given profile specification.

Parameters
  • buf – Original buffered raw record data.

  • profile – Profile family identifier the profile belongs.

  • version – On success populated by found version number.

Returns

0 on success, negative value if error occurred during processing.

int bt_sdp_get_features(const struct net_buf *buf, uint16_t *features)

Get SupportedFeatures attribute value.

Allows if exposed by remote retrieve SupportedFeature attribute.

Parameters
  • buf – Buffer holding original raw record data from remote.

  • features – On success object to be populated with SupportedFeature mask.

Returns

0 on success if feature found and valid, negative in case any error

struct bt_sdp_data_elem
#include <sdp.h>

SDP Generic Data Element Value.

struct bt_sdp_attribute
#include <sdp.h>

SDP Attribute Value.

struct bt_sdp_record
#include <sdp.h>

SDP Service Record Value.

struct bt_sdp_client_result
#include <sdp.h>

Generic SDP Client Query Result data holder.

struct bt_sdp_discover_params
#include <sdp.h>

Main user structure used in SDP discovery of remote.

Public Members

const struct bt_uuid *uuid

UUID (service) to be discovered on remote SDP entity

bt_sdp_discover_func_t func

Discover callback to be called on resolved SDP record

struct net_buf_pool *pool

Memory buffer enabled by user for SDP query results