Service Discovery Protocol (SDP)

API Reference

group bt_sdp

Service class identifiers of standard services and service groups

BT_SDP_SDP_SERVER_SVCLASS

Service Discovery Server.

BT_SDP_BROWSE_GRP_DESC_SVCLASS

Browse Group Descriptor.

BT_SDP_PUBLIC_BROWSE_GROUP

Public Browse Group.

BT_SDP_SERIAL_PORT_SVCLASS

Serial Port.

BT_SDP_LAN_ACCESS_SVCLASS

LAN Access Using PPP.

BT_SDP_DIALUP_NET_SVCLASS

Dialup Networking.

BT_SDP_IRMC_SYNC_SVCLASS

IrMC Sync.

BT_SDP_OBEX_OBJPUSH_SVCLASS

OBEX Object Push.

BT_SDP_OBEX_FILETRANS_SVCLASS

OBEX File Transfer.

BT_SDP_IRMC_SYNC_CMD_SVCLASS

IrMC Sync Command.

BT_SDP_HEADSET_SVCLASS

Headset.

BT_SDP_CORDLESS_TELEPHONY_SVCLASS

Cordless Telephony.

BT_SDP_AUDIO_SOURCE_SVCLASS

Audio Source.

BT_SDP_AUDIO_SINK_SVCLASS

Audio Sink.

BT_SDP_AV_REMOTE_TARGET_SVCLASS

A/V Remote Control Target.

BT_SDP_ADVANCED_AUDIO_SVCLASS

Advanced Audio Distribution.

BT_SDP_AV_REMOTE_SVCLASS

A/V Remote Control.

BT_SDP_AV_REMOTE_CONTROLLER_SVCLASS

A/V Remote Control Controller.

BT_SDP_INTERCOM_SVCLASS

Intercom.

BT_SDP_FAX_SVCLASS

Fax.

BT_SDP_HEADSET_AGW_SVCLASS

Headset AG.

BT_SDP_WAP_SVCLASS

WAP.

BT_SDP_WAP_CLIENT_SVCLASS

WAP Client.

BT_SDP_PANU_SVCLASS

Personal Area Networking User.

BT_SDP_NAP_SVCLASS

Network Access Point.

BT_SDP_GN_SVCLASS

Group Network.

BT_SDP_DIRECT_PRINTING_SVCLASS

Direct Printing.

BT_SDP_REFERENCE_PRINTING_SVCLASS

Reference Printing.

BT_SDP_IMAGING_SVCLASS

Basic Imaging Profile.

BT_SDP_IMAGING_RESPONDER_SVCLASS

Imaging Responder.

BT_SDP_IMAGING_ARCHIVE_SVCLASS

Imaging Automatic Archive.

BT_SDP_IMAGING_REFOBJS_SVCLASS

Imaging Referenced Objects.

BT_SDP_HANDSFREE_SVCLASS

Handsfree.

BT_SDP_HANDSFREE_AGW_SVCLASS

Handsfree Audio Gateway.

BT_SDP_DIRECT_PRT_REFOBJS_SVCLASS

Direct Printing Reference Objects Service.

BT_SDP_REFLECTED_UI_SVCLASS

Reflected UI.

BT_SDP_BASIC_PRINTING_SVCLASS

Basic Printing.

BT_SDP_PRINTING_STATUS_SVCLASS

Printing Status.

BT_SDP_HID_SVCLASS

Human Interface Device Service.

BT_SDP_HCR_SVCLASS

Hardcopy Cable Replacement.

BT_SDP_HCR_PRINT_SVCLASS

HCR Print.

BT_SDP_HCR_SCAN_SVCLASS

HCR Scan.

BT_SDP_CIP_SVCLASS

Common ISDN Access.

BT_SDP_VIDEO_CONF_GW_SVCLASS

Video Conferencing Gateway.

BT_SDP_UDI_MT_SVCLASS

UDI MT.

BT_SDP_UDI_TA_SVCLASS

UDI TA.

BT_SDP_AV_SVCLASS

Audio/Video.

BT_SDP_SAP_SVCLASS

SIM Access.

BT_SDP_PBAP_PCE_SVCLASS

Phonebook Access Client.

BT_SDP_PBAP_PSE_SVCLASS

Phonebook Access Server.

BT_SDP_PBAP_SVCLASS

Phonebook Access.

BT_SDP_MAP_MSE_SVCLASS

Message Access Server.

BT_SDP_MAP_MCE_SVCLASS

Message Notification Server.

BT_SDP_MAP_SVCLASS

Message Access Profile.

BT_SDP_GNSS_SVCLASS

GNSS.

BT_SDP_GNSS_SERVER_SVCLASS

GNSS Server.

BT_SDP_MPS_SC_SVCLASS

MPS SC.

BT_SDP_MPS_SVCLASS

MPS.

BT_SDP_PNP_INFO_SVCLASS

PnP Information.

BT_SDP_GENERIC_NETWORKING_SVCLASS

Generic Networking.

BT_SDP_GENERIC_FILETRANS_SVCLASS

Generic File Transfer.

BT_SDP_GENERIC_AUDIO_SVCLASS

Generic Audio.

BT_SDP_GENERIC_TELEPHONY_SVCLASS

Generic Telephony.

BT_SDP_UPNP_SVCLASS

UPnP Service.

BT_SDP_UPNP_IP_SVCLASS

UPnP IP Service.

BT_SDP_UPNP_PAN_SVCLASS

UPnP IP PAN.

BT_SDP_UPNP_LAP_SVCLASS

UPnP IP LAP.

BT_SDP_UPNP_L2CAP_SVCLASS

UPnP IP L2CAP.

BT_SDP_VIDEO_SOURCE_SVCLASS

Video Source.

BT_SDP_VIDEO_SINK_SVCLASS

Video Sink.

BT_SDP_VIDEO_DISTRIBUTION_SVCLASS

Video Distribution.

BT_SDP_HDP_SVCLASS

HDP.

BT_SDP_HDP_SOURCE_SVCLASS

HDP Source.

BT_SDP_HDP_SINK_SVCLASS

HDP Sink.

BT_SDP_GENERIC_ACCESS_SVCLASS

Generic Access Profile.

BT_SDP_GENERIC_ATTRIB_SVCLASS

Generic Attribute Profile.

BT_SDP_APPLE_AGENT_SVCLASS

Apple Agent.

Attribute identifier codes

Possible values for attribute-id are listed below.

See SDP Spec, section “Service Attribute Definitions” for more details.

BT_SDP_ATTR_RECORD_HANDLE

Service Record Handle.

BT_SDP_ATTR_SVCLASS_ID_LIST

Service Class ID List.

BT_SDP_ATTR_RECORD_STATE

Service Record State.

BT_SDP_ATTR_SERVICE_ID

Service ID.

BT_SDP_ATTR_PROTO_DESC_LIST

Protocol Descriptor List.

BT_SDP_ATTR_BROWSE_GRP_LIST

Browse Group List.

BT_SDP_ATTR_LANG_BASE_ATTR_ID_LIST

Language Base Attribute ID List.

BT_SDP_ATTR_SVCINFO_TTL

Service Info Time to Live.

BT_SDP_ATTR_SERVICE_AVAILABILITY

Service Availability.

BT_SDP_ATTR_PROFILE_DESC_LIST

Bluetooth Profile Descriptor List.

BT_SDP_ATTR_DOC_URL

Documentation URL.

BT_SDP_ATTR_CLNT_EXEC_URL

Client Executable URL.

BT_SDP_ATTR_ICON_URL

Icon URL.

BT_SDP_ATTR_ADD_PROTO_DESC_LIST

Additional Protocol Descriptor List.

BT_SDP_ATTR_GROUP_ID

Group ID.

BT_SDP_ATTR_IP_SUBNET

IP Subnet.

BT_SDP_ATTR_VERSION_NUM_LIST

Version Number List.

BT_SDP_ATTR_SUPPORTED_FEATURES_LIST

Supported Features List.

BT_SDP_ATTR_GOEP_L2CAP_PSM

GOEP L2CAP PSM.

BT_SDP_ATTR_SVCDB_STATE

Service Database State.

BT_SDP_ATTR_MPSD_SCENARIOS

MPSD Scenarios.

BT_SDP_ATTR_MPMD_SCENARIOS

MPMD Scenarios.

BT_SDP_ATTR_MPS_DEPENDENCIES

Supported Profiles & Protocols.

BT_SDP_ATTR_SERVICE_VERSION

Service Version.

BT_SDP_ATTR_EXTERNAL_NETWORK

External Network.

BT_SDP_ATTR_SUPPORTED_DATA_STORES_LIST

Supported Data Stores List.

BT_SDP_ATTR_DATA_EXCHANGE_SPEC

Data Exchange Specification.

BT_SDP_ATTR_NETWORK

Network.

BT_SDP_ATTR_FAX_CLASS1_SUPPORT

Fax Class 1 Support.

BT_SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL

Remote Audio Volume Control.

BT_SDP_ATTR_MCAP_SUPPORTED_PROCEDURES

MCAP Supported Procedures.

BT_SDP_ATTR_FAX_CLASS20_SUPPORT

Fax Class 2.0 Support.

BT_SDP_ATTR_SUPPORTED_FORMATS_LIST

Supported Formats List.

BT_SDP_ATTR_FAX_CLASS2_SUPPORT

Fax Class 2 Support (vendor-specific)

BT_SDP_ATTR_AUDIO_FEEDBACK_SUPPORT

Audio Feedback Support.

BT_SDP_ATTR_NETWORK_ADDRESS

Network Address.

BT_SDP_ATTR_WAP_GATEWAY

WAP Gateway.

BT_SDP_ATTR_HOMEPAGE_URL

Homepage URL.

BT_SDP_ATTR_WAP_STACK_TYPE

WAP Stack Type.

BT_SDP_ATTR_SECURITY_DESC

Security Description.

BT_SDP_ATTR_NET_ACCESS_TYPE

Net Access Type.

BT_SDP_ATTR_MAX_NET_ACCESSRATE

Max Net Access Rate.

BT_SDP_ATTR_IP4_SUBNET

IPv4 Subnet.

BT_SDP_ATTR_IP6_SUBNET

IPv6 Subnet.

BT_SDP_ATTR_SUPPORTED_CAPABILITIES

BIP Supported Capabilities.

BT_SDP_ATTR_SUPPORTED_FEATURES

BIP Supported Features.

BT_SDP_ATTR_SUPPORTED_FUNCTIONS

BIP Supported Functions.

BT_SDP_ATTR_TOTAL_IMAGING_DATA_CAPACITY

BIP Total Imaging Data Capacity.

BT_SDP_ATTR_SUPPORTED_REPOSITORIES

Supported Repositories.

BT_SDP_ATTR_MAS_INSTANCE_ID

MAS Instance ID.

BT_SDP_ATTR_SUPPORTED_MESSAGE_TYPES

Supported Message Types.

BT_SDP_ATTR_PBAP_SUPPORTED_FEATURES

PBAP Supported Features.

BT_SDP_ATTR_MAP_SUPPORTED_FEATURES

MAP Supported Features.

BT_SDP_ATTR_SPECIFICATION_ID

Specification ID.

BT_SDP_ATTR_VENDOR_ID

Vendor ID.

BT_SDP_ATTR_PRODUCT_ID

Product ID.

BT_SDP_ATTR_VERSION

Version.

BT_SDP_ATTR_PRIMARY_RECORD

Primary Record.

BT_SDP_ATTR_VENDOR_ID_SOURCE

Vendor ID Source.

BT_SDP_ATTR_HID_DEVICE_RELEASE_NUMBER

HID Device Release Number.

BT_SDP_ATTR_HID_PARSER_VERSION

HID Parser Version.

BT_SDP_ATTR_HID_DEVICE_SUBCLASS

HID Device Subclass.

BT_SDP_ATTR_HID_COUNTRY_CODE

HID Country Code.

BT_SDP_ATTR_HID_VIRTUAL_CABLE

HID Virtual Cable.

BT_SDP_ATTR_HID_RECONNECT_INITIATE

HID Reconnect Initiate.

BT_SDP_ATTR_HID_DESCRIPTOR_LIST

HID Descriptor List.

BT_SDP_ATTR_HID_LANG_ID_BASE_LIST

HID Language ID Base List.

BT_SDP_ATTR_HID_SDP_DISABLE

HID SDP Disable.

BT_SDP_ATTR_HID_BATTERY_POWER

HID Battery Power.

BT_SDP_ATTR_HID_REMOTE_WAKEUP

HID Remote Wakeup.

BT_SDP_ATTR_HID_PROFILE_VERSION

HID Profile Version.

BT_SDP_ATTR_HID_SUPERVISION_TIMEOUT

HID Supervision Timeout.

BT_SDP_ATTR_HID_NORMALLY_CONNECTABLE

HID Normally Connectable.

BT_SDP_ATTR_HID_BOOT_DEVICE

HID Boot Device.

The Data representation in SDP PDUs (pps 339, 340 of BT SDP Spec)

These are the exact data type+size descriptor values that go into the PDU buffer.

The datatype (leading 5bits) + size descriptor (last 3 bits) is 8 bits. The size descriptor is critical to extract the right number of bytes for the data value from the PDU.

For most basic types, the datatype+size descriptor is straightforward. However for constructed types and strings, the size of the data is in the next “n” bytes following the 8 bits (datatype+size) descriptor. Exactly what the “n” is specified in the 3 bits of the data size descriptor.

TextString and URLString can be of size 2^{8, 16, 32} bytes DataSequence and DataSequenceAlternates can be of size 2^{8, 16, 32} The size are computed post-facto in the API and are not known apriori.

BT_SDP_DATA_NIL

Nil, the null type.

BT_SDP_UINT8

Unsigned 8-bit integer.

BT_SDP_UINT16

Unsigned 16-bit integer.

BT_SDP_UINT32

Unsigned 32-bit integer.

BT_SDP_UINT64

Unsigned 64-bit integer.

BT_SDP_UINT128

Unsigned 128-bit integer.

BT_SDP_INT8

Signed 8-bit integer.

BT_SDP_INT16

Signed 16-bit integer.

BT_SDP_INT32

Signed 32-bit integer.

BT_SDP_INT64

Signed 64-bit integer.

BT_SDP_INT128

Signed 128-bit integer.

BT_SDP_UUID_UNSPEC

UUID, unspecified size.

BT_SDP_UUID16

UUID, 16-bit.

BT_SDP_UUID32

UUID, 32-bit.

BT_SDP_UUID128

UUID, 128-bit.

BT_SDP_TEXT_STR_UNSPEC

Text string, unspecified size.

BT_SDP_TEXT_STR8

Text string, 8-bit length.

BT_SDP_TEXT_STR16

Text string, 16-bit length.

BT_SDP_TEXT_STR32

Text string, 32-bit length.

BT_SDP_BOOL

Boolean.

BT_SDP_SEQ_UNSPEC

Data element sequence, unspecified size.

BT_SDP_SEQ8

Data element sequence, 8-bit length.

BT_SDP_SEQ16

Data element sequence, 16-bit length.

BT_SDP_SEQ32

Data element sequence, 32-bit length.

BT_SDP_ALT_UNSPEC

Data element alternative, unspecified size.

BT_SDP_ALT8

Data element alternative, 8-bit length.

BT_SDP_ALT16

Data element alternative, 16-bit length.

BT_SDP_ALT32

Data element alternative, 32-bit length.

BT_SDP_URL_STR_UNSPEC

URL string, unspecified size.

BT_SDP_URL_STR8

URL string, 8-bit length.

BT_SDP_URL_STR16

URL string, 16-bit length.

BT_SDP_URL_STR32

URL string, 32-bit length.

Defines

BT_SDP_SERVER_RECORD_HANDLE
BT_SDP_PRIMARY_LANG_BASE
BT_SDP_ATTR_SVCNAME_PRIMARY
BT_SDP_ATTR_SVCDESC_PRIMARY
BT_SDP_ATTR_PROVNAME_PRIMARY
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

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 related 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.

Public Members

uint8_t type

Type of the data element.

uint32_t data_size

Size of the data element.

uint32_t total_size

Total size of the data element.

struct bt_sdp_attribute
#include <sdp.h>

SDP Attribute Value.

Public Members

uint16_t id

Attribute ID.

struct bt_sdp_data_elem val

Attribute data.

struct bt_sdp_record
#include <sdp.h>

SDP Service Record Value.

Public Members

uint32_t handle

Redundant, for quick ref.

struct bt_sdp_attribute *attrs

Base addr of attr array.

size_t attr_count

Number of attributes.

uint8_t index

Index of the record in LL.

struct bt_sdp_record *next

Next service record.

struct bt_sdp_client_result
#include <sdp.h>

Generic SDP Client Query Result data holder.

Public Members

struct net_buf *resp_buf

buffer containing unparsed SDP record result for given UUID

bool next_record_hint

flag pointing that there are more result chunks for given UUID

const struct bt_uuid *uuid

Reference to UUID object on behalf one discovery was started.

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