119e95205Sopenharmony_ci/*
219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
419e95205Sopenharmony_ci * you may not use this file except in compliance with the License.
519e95205Sopenharmony_ci * You may obtain a copy of the License at
619e95205Sopenharmony_ci *
719e95205Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
819e95205Sopenharmony_ci *
919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and
1319e95205Sopenharmony_ci * limitations under the License.
1419e95205Sopenharmony_ci */
1519e95205Sopenharmony_ci
1619e95205Sopenharmony_ci/**
1719e95205Sopenharmony_ci * @addtogroup Bluetooth
1819e95205Sopenharmony_ci * @{
1919e95205Sopenharmony_ci *
2019e95205Sopenharmony_ci * @brief This file is a part of BTStack.
2119e95205Sopenharmony_ci *
2219e95205Sopenharmony_ci */
2319e95205Sopenharmony_ci
2419e95205Sopenharmony_ci/**
2519e95205Sopenharmony_ci * @file sdp.h
2619e95205Sopenharmony_ci *
2719e95205Sopenharmony_ci * @brief Service discovery protocol (SDP) interface.
2819e95205Sopenharmony_ci *
2919e95205Sopenharmony_ci */
3019e95205Sopenharmony_ci#ifndef SDP_H
3119e95205Sopenharmony_ci#define SDP_H
3219e95205Sopenharmony_ci
3319e95205Sopenharmony_ci#include <stdlib.h>
3419e95205Sopenharmony_ci#include <stdbool.h>
3519e95205Sopenharmony_ci
3619e95205Sopenharmony_ci#include "btstack.h"
3719e95205Sopenharmony_ci
3819e95205Sopenharmony_ci#ifdef __cplusplus
3919e95205Sopenharmony_ciextern "C" {
4019e95205Sopenharmony_ci#endif
4119e95205Sopenharmony_ci
4219e95205Sopenharmony_ci/* Define service class UUIDs */
4319e95205Sopenharmony_ci#define SDP_PUBLIC_BROWSE_GROUP_ROOT_UUID 0x1002
4419e95205Sopenharmony_ci
4519e95205Sopenharmony_ci/* Define service attribute IDs. */
4619e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_RECORD_HANDLE 0x0000
4719e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_CLASS_ID_LIST 0x0001
4819e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_RECORD_STATE 0x0002
4919e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_ID 0x0003
5019e95205Sopenharmony_ci#define SDP_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST 0x0004
5119e95205Sopenharmony_ci#define SDP_ATTRIBUTE_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST 0x000D
5219e95205Sopenharmony_ci#define SDP_ATTRIBUTE_BROWSE_GROUP_LIST 0x0005
5319e95205Sopenharmony_ci#define SDP_ATTRIBUTE_LANGUAGE_BASE_ATTRIBUTE_ID_LIST 0x0006
5419e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_INFO_TIME_TO_LIVE 0x0007
5519e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_AVAILABILITY 0x0008
5619e95205Sopenharmony_ci#define SDP_ATTRIBUTE_BLUETOOTH_PROFILE_DESCRIPTOR_LIST 0x0009
5719e95205Sopenharmony_ci#define SDP_ATTRIBUTE_DOCUMENTATION_URL 0x000A
5819e95205Sopenharmony_ci#define SDP_ATTRIBUTE_CLIENT_EXECUTABLE_URL 0x000B
5919e95205Sopenharmony_ci#define SDP_ATTRIBUTE_ICON_URL 0x000C
6019e95205Sopenharmony_ci#define SDP_ATTRIBUTE_SERVICE_NAME 0x0000
6119e95205Sopenharmony_ci#define SDP_ATTRIBUTE_DESCRIPTOR 0x0001
6219e95205Sopenharmony_ci#define SDP_ATTRIBUTE_PROVIDER_NAME 0x0002
6319e95205Sopenharmony_ci
6419e95205Sopenharmony_ci/* Define base attribute ID value for the primary language. */
6519e95205Sopenharmony_ci#define SDP_ATTRIBUTE_PRIMARY_LANGUAGE_BASE 0x0100
6619e95205Sopenharmony_ci
6719e95205Sopenharmony_ci/* Define protocol UUIDs. */
6819e95205Sopenharmony_ci#define UUID_PROTOCOL_SDP 0x0001
6919e95205Sopenharmony_ci#define UUID_PROTOCOL_RFCOMM 0x0003
7019e95205Sopenharmony_ci#define UUID_PROTOCOL_ATT 0x0007
7119e95205Sopenharmony_ci#define UUID_PROTOCOL_OBEX 0x0008
7219e95205Sopenharmony_ci#define UUID_PROTOCOL_AVCTP 0x0017
7319e95205Sopenharmony_ci#define UUID_PROTOCOL_AVDTP 0x0019
7419e95205Sopenharmony_ci#define UUID_PROTOCOL_AVCTP_BROWSING 0x001B
7519e95205Sopenharmony_ci#define UUID_PROTOCOL_L2CAP 0x0100
7619e95205Sopenharmony_ci
7719e95205Sopenharmony_ci/* Define specified buffer size. */
7819e95205Sopenharmony_ci#define SDP_PROTOCOL_PARAMETER_MAX_COUNT 4
7919e95205Sopenharmony_ci#define SDP_PROTOCOL_DESCRIPTOR_MAX_COUNT 4
8019e95205Sopenharmony_ci#define SDP_ATTRIBUTE_ID_LIST_MAX_COUNT 12
8119e95205Sopenharmony_ci
8219e95205Sopenharmony_ci/* Data type. */
8319e95205Sopenharmony_citypedef enum {
8419e95205Sopenharmony_ci    SDP_TYPE_BOOL,
8519e95205Sopenharmony_ci    SDP_TYPE_UINT_8,
8619e95205Sopenharmony_ci    SDP_TYPE_UINT_16,
8719e95205Sopenharmony_ci    SDP_TYPE_UINT_32,
8819e95205Sopenharmony_ci    SDP_TYPE_INT_8,
8919e95205Sopenharmony_ci    SDP_TYPE_INT_16,
9019e95205Sopenharmony_ci    SDP_TYPE_INT_32,
9119e95205Sopenharmony_ci    SDP_TYPE_UUID_16,
9219e95205Sopenharmony_ci    SDP_TYPE_UUID_32,
9319e95205Sopenharmony_ci    SDP_TYPE_UUID_128,
9419e95205Sopenharmony_ci    SDP_TYPE_TEXT,
9519e95205Sopenharmony_ci    SDP_TYPE_URL,
9619e95205Sopenharmony_ci} SdpDataType;
9719e95205Sopenharmony_ci
9819e95205Sopenharmony_ci/**
9919e95205Sopenharmony_ci *  @brief Protocol patameter
10019e95205Sopenharmony_ci */
10119e95205Sopenharmony_citypedef struct {
10219e95205Sopenharmony_ci    SdpDataType type;
10319e95205Sopenharmony_ci    uint32_t value;
10419e95205Sopenharmony_ci} SdpProtocolParameter;
10519e95205Sopenharmony_ci
10619e95205Sopenharmony_ci/**
10719e95205Sopenharmony_ci *  @brief Protocol descriptor
10819e95205Sopenharmony_ci */
10919e95205Sopenharmony_citypedef struct {
11019e95205Sopenharmony_ci    BtUuid protocolUuid;
11119e95205Sopenharmony_ci    uint16_t parameterNumber;
11219e95205Sopenharmony_ci    SdpProtocolParameter parameter[SDP_PROTOCOL_PARAMETER_MAX_COUNT];
11319e95205Sopenharmony_ci} SdpProtocolDescriptor;
11419e95205Sopenharmony_ci
11519e95205Sopenharmony_ci/**
11619e95205Sopenharmony_ci *  @brief Additional protocol descriptor
11719e95205Sopenharmony_ci */
11819e95205Sopenharmony_citypedef struct {
11919e95205Sopenharmony_ci    uint16_t protocolDescriptorNumber;
12019e95205Sopenharmony_ci    SdpProtocolDescriptor parameter[SDP_PROTOCOL_DESCRIPTOR_MAX_COUNT];
12119e95205Sopenharmony_ci} SdpAdditionalProtocolDescriptor;
12219e95205Sopenharmony_ci
12319e95205Sopenharmony_ci/**
12419e95205Sopenharmony_ci *  @brief Language attribute
12519e95205Sopenharmony_ci */
12619e95205Sopenharmony_citypedef struct {
12719e95205Sopenharmony_ci    uint16_t languageIdentifier;
12819e95205Sopenharmony_ci    uint16_t characterEncodingIdentifier;
12919e95205Sopenharmony_ci    uint16_t baseAttributeId;
13019e95205Sopenharmony_ci} SdpLanguageBaseAttributeId;
13119e95205Sopenharmony_ci
13219e95205Sopenharmony_ci/**
13319e95205Sopenharmony_ci *  @brief Profile descriptor
13419e95205Sopenharmony_ci */
13519e95205Sopenharmony_citypedef struct {
13619e95205Sopenharmony_ci    BtUuid profileUuid;
13719e95205Sopenharmony_ci    uint16_t versionNumber;
13819e95205Sopenharmony_ci} SdpProfileDescriptor;
13919e95205Sopenharmony_ci
14019e95205Sopenharmony_ci/**
14119e95205Sopenharmony_ci * @brief  Create service record.
14219e95205Sopenharmony_ci *
14319e95205Sopenharmony_ci * @return Returns service record handle value.
14419e95205Sopenharmony_ci */
14519e95205Sopenharmony_ciuint32_t BTSTACK_API SDP_CreateServiceRecord();
14619e95205Sopenharmony_ci
14719e95205Sopenharmony_ci/**
14819e95205Sopenharmony_ci * @brief Destroy service record.
14919e95205Sopenharmony_ci *
15019e95205Sopenharmony_ci * @param handle Service record handle.
15119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
15219e95205Sopenharmony_ci */
15319e95205Sopenharmony_ciint BTSTACK_API SDP_DestroyServiceRecord(uint32_t handle);
15419e95205Sopenharmony_ci
15519e95205Sopenharmony_ci/**
15619e95205Sopenharmony_ci * @brief Register service record.
15719e95205Sopenharmony_ci *
15819e95205Sopenharmony_ci * @param handle Service record handle.
15919e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
16019e95205Sopenharmony_ci */
16119e95205Sopenharmony_ciint BTSTACK_API SDP_RegisterServiceRecord(uint32_t handle);
16219e95205Sopenharmony_ci
16319e95205Sopenharmony_ci/**
16419e95205Sopenharmony_ci * @brief Deregister service record.
16519e95205Sopenharmony_ci *
16619e95205Sopenharmony_ci * @param handle Service record handle.
16719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
16819e95205Sopenharmony_ci */
16919e95205Sopenharmony_ciint BTSTACK_API SDP_DeregisterServiceRecord(uint32_t handle);
17019e95205Sopenharmony_ci
17119e95205Sopenharmony_ci/**
17219e95205Sopenharmony_ci * @brief Add ServiceClassIDList Attribute to service record. The ServiceClassIDList shall contain
17319e95205Sopenharmony_ci *        at least one service class UUID. Refer to charter 5.1.2 of Core 5.0.
17419e95205Sopenharmony_ci *
17519e95205Sopenharmony_ci * @param handle  Service record handle.
17619e95205Sopenharmony_ci * @param classid The list of UUIDs representing the service classes.
17719e95205Sopenharmony_ci * @param classidNumber The number of classid.
17819e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
17919e95205Sopenharmony_ci */
18019e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceClassIdList(uint32_t handle, const BtUuid *classid, uint16_t classidNumber);
18119e95205Sopenharmony_ci
18219e95205Sopenharmony_ci/**
18319e95205Sopenharmony_ci * @brief Add ServiceRecordState Attribute to service record. Refer to charter 5.1.3 of Core 5.0.
18419e95205Sopenharmony_ci *
18519e95205Sopenharmony_ci * @param handle Service record handle.
18619e95205Sopenharmony_ci * @param state  Service record state.
18719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
18819e95205Sopenharmony_ci */
18919e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceRecordState(uint32_t handle, uint32_t state);
19019e95205Sopenharmony_ci
19119e95205Sopenharmony_ci/**
19219e95205Sopenharmony_ci * @brief Add ServiceRecordState Attribute to service record. Refer to charter 5.1.4 of Core 5.0.
19319e95205Sopenharmony_ci *
19419e95205Sopenharmony_ci * @param handle    Service record handle.
19519e95205Sopenharmony_ci * @param serviceid The UUID that uniquely identifies the service.
19619e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
19719e95205Sopenharmony_ci */
19819e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceId(uint32_t handle, const BtUuid *serviceid);
19919e95205Sopenharmony_ci
20019e95205Sopenharmony_ci/**
20119e95205Sopenharmony_ci * @brief Add ProtocolDescriptorList Attribute to record. The ProtocolDescriptorList attribute
20219e95205Sopenharmony_ci *        describes one or more protocol stacks that can be used to gain access to the service
20319e95205Sopenharmony_ci *        described by the service record.Refer to charter 5.1.5 of Core 5.0.
20419e95205Sopenharmony_ci *
20519e95205Sopenharmony_ci * @param handle     Service record handle.
20619e95205Sopenharmony_ci * @param descriptor One or more protocol descriptor.
20719e95205Sopenharmony_ci * @param descriptorNumber The number of protocol.
20819e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
20919e95205Sopenharmony_ci */
21019e95205Sopenharmony_ciint BTSTACK_API SDP_AddProtocolDescriptorList(
21119e95205Sopenharmony_ci    uint32_t handle, const SdpProtocolDescriptor *descriptor, uint16_t descriptorNumber);
21219e95205Sopenharmony_ci
21319e95205Sopenharmony_ci/**
21419e95205Sopenharmony_ci * @brief Add AdditionalProtocolDescriptorList Attribute to record. The AdditionalProtocolDescriptorLists
21519e95205Sopenharmony_ci *        attribute supports services that require more channels in addition to the service described
21619e95205Sopenharmony_ci *        in ProtocolDescriptorList. Refer to charter 5.1.6 of Core 5.0.
21719e95205Sopenharmony_ci *
21819e95205Sopenharmony_ci * @param handle           Service record handle.
21919e95205Sopenharmony_ci * @param descriptorList   A sequence of ProtocolDescriptorList-elements.
22019e95205Sopenharmony_ci * @param descriptorNumber The number of ProtocolDescriptorList-element.
22119e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
22219e95205Sopenharmony_ci */
22319e95205Sopenharmony_ciint BTSTACK_API SDP_AddAdditionalProtocolDescriptorList(
22419e95205Sopenharmony_ci    uint32_t handle, const SdpAdditionalProtocolDescriptor *descriptorList, uint16_t descriptorListNumber);
22519e95205Sopenharmony_ci
22619e95205Sopenharmony_ci/**
22719e95205Sopenharmony_ci * @brief Add BrowseGroupList Attribute to record. The top-level browse group ID, called PublicBrowseRoot
22819e95205Sopenharmony_ci *        and representing the root of the browsing hierarchy, has the default value 0x1002 (UUID16).
22919e95205Sopenharmony_ci *        Refer to charter 5.1.7 of Core 5.0.
23019e95205Sopenharmony_ci *
23119e95205Sopenharmony_ci * @param handle           Service record handle.
23219e95205Sopenharmony_ci * @param browseUuid       The list of UUIDs that represents a browse group.
23319e95205Sopenharmony_ci * @param browseUuidNumber The number of UUIDs
23419e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
23519e95205Sopenharmony_ci */
23619e95205Sopenharmony_ciint BTSTACK_API SDP_AddBrowseGroupList(uint32_t handle, const BtUuid *browseUuid, uint16_t browseUuidNumber);
23719e95205Sopenharmony_ci
23819e95205Sopenharmony_ci/**
23919e95205Sopenharmony_ci * @brief Add LanguageBaseAttributeIDList Attribute to record. The LanguageBaseAttributeIDList attribute
24019e95205Sopenharmony_ci *        is a list in which each member containsa language identifier, a character encoding identifier,
24119e95205Sopenharmony_ci *        and a base attribute ID for each of the natural languages used in the service record.
24219e95205Sopenharmony_ci *        Refer to charter 5.1.8 of Core 5.0.
24319e95205Sopenharmony_ci *
24419e95205Sopenharmony_ci * @param handle                Service record handle.
24519e95205Sopenharmony_ci * @param baseAttributeId       The list of the natural languages' attribute IDs.
24619e95205Sopenharmony_ci * @param baseAttributeIdNum the number of the natural languages used in the service record.
24719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
24819e95205Sopenharmony_ci */
24919e95205Sopenharmony_ciint BTSTACK_API SDP_AddLanguageBaseAttributeIdList(
25019e95205Sopenharmony_ci    uint32_t handle, const SdpLanguageBaseAttributeId *baseAttributeId, uint16_t baseAttributeIdNum);
25119e95205Sopenharmony_ci
25219e95205Sopenharmony_ci/**
25319e95205Sopenharmony_ci * @brief Add ServiceInfoTimeToLive Attribute to record. The ServiceTimeToLive attribute is a 32-bit
25419e95205Sopenharmony_ci *        integer that contains the number of seconds for which the information in a service record
25519e95205Sopenharmony_ci *        is expected to remain valid and unchanged. Refer to charter 5.1.9 of Core 5.0.
25619e95205Sopenharmony_ci *
25719e95205Sopenharmony_ci * @param handle Service record handle.
25819e95205Sopenharmony_ci * @param value  Time interval in seconds.
25919e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
26019e95205Sopenharmony_ci */
26119e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceInfoTimeToLive(uint32_t handle, uint32_t value);
26219e95205Sopenharmony_ci
26319e95205Sopenharmony_ci/**
26419e95205Sopenharmony_ci * @brief Add ServiceAvailability Attribute to record. The ServiceAvailability attribute is an 8-bit unsigned
26519e95205Sopenharmony_ci *        integer that represents therelative ability of the service to accept additional clients.
26619e95205Sopenharmony_ci *        Refer to charter 5.1.10 of Core 5.0.
26719e95205Sopenharmony_ci *
26819e95205Sopenharmony_ci * @param handle Service record handle.
26919e95205Sopenharmony_ci * @param value  The relative ability of the service (idle - 0xFF, busy - 0x00).
27019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
27119e95205Sopenharmony_ci */
27219e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceAvailability(uint32_t handle, uint8_t value);
27319e95205Sopenharmony_ci
27419e95205Sopenharmony_ci/**
27519e95205Sopenharmony_ci * @brief Add BluetoothProfileDescriptorList Attribute to record. The BluetoothProfileDescriptorList attribute
27619e95205Sopenharmony_ci *        consists of a data element sequence in which each element is a profile descriptor contains information
27719e95205Sopenharmony_ci *        about a Bluetooth profile to which the service represented by this service record conforms.
27819e95205Sopenharmony_ci *        Refer to charter 5.1.11 of Core 5.0.
27919e95205Sopenharmony_ci *
28019e95205Sopenharmony_ci * @param handle                  Service record handle.
28119e95205Sopenharmony_ci * @param profileDescriptor       The list of UUIDs and a 16-bit profile version number.
28219e95205Sopenharmony_ci * @param profileDescriptorNum The number of profile descriptors.
28319e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
28419e95205Sopenharmony_ci */
28519e95205Sopenharmony_ciint BTSTACK_API SDP_AddBluetoothProfileDescriptorList(
28619e95205Sopenharmony_ci    uint32_t handle, const SdpProfileDescriptor *profileDescriptor, uint16_t profileDescriptorNum);
28719e95205Sopenharmony_ci
28819e95205Sopenharmony_ci/**
28919e95205Sopenharmony_ci * @brief Add DocumentationURL Attribute to record. The DocumentationURL attribute is a URL which points to
29019e95205Sopenharmony_ci *        documentation on the service described by a service record. Refer to charter 5.1.12 of Core 5.0.
29119e95205Sopenharmony_ci *
29219e95205Sopenharmony_ci * @param handle Service record handle.
29319e95205Sopenharmony_ci * @param url    The documentation url.
29419e95205Sopenharmony_ci * @param urlLen The length of url.
29519e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
29619e95205Sopenharmony_ci */
29719e95205Sopenharmony_ciint BTSTACK_API SDP_AddDocumentationUrl(uint32_t handle, const uint8_t *url, uint16_t urlLen);
29819e95205Sopenharmony_ci
29919e95205Sopenharmony_ci/**
30019e95205Sopenharmony_ci * @brief Add ClientExecutableURL Attribute to record. The ClientExecutableURL attribute is a URL that refers to
30119e95205Sopenharmony_ci *        the location of an application that can be used to utilize the service described by the service record.
30219e95205Sopenharmony_ci *        Refer to charter 5.1.13 of Core 5.0.
30319e95205Sopenharmony_ci *
30419e95205Sopenharmony_ci * @param handle Service record handle.
30519e95205Sopenharmony_ci * @param url    The client executable url.
30619e95205Sopenharmony_ci * @param urlLen The length of url.
30719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
30819e95205Sopenharmony_ci */
30919e95205Sopenharmony_ciint BTSTACK_API SDP_AddClientExecutableUrl(uint32_t handle, const uint8_t *url, uint16_t urlLen);
31019e95205Sopenharmony_ci
31119e95205Sopenharmony_ci/**
31219e95205Sopenharmony_ci * @brief Add IconURL Attribute to record. The IconURL attribute is a URL that refers to the location of an icon that
31319e95205Sopenharmony_ci *        can be used to represent the service described by the service record. Refer to charter 5.1.14 of Core 5.0.
31419e95205Sopenharmony_ci *
31519e95205Sopenharmony_ci * @param handle Service record handle.
31619e95205Sopenharmony_ci * @param url    The icon url.
31719e95205Sopenharmony_ci * @param urlLen The length of url.
31819e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
31919e95205Sopenharmony_ci */
32019e95205Sopenharmony_ciint BTSTACK_API SDP_AddIconUrl(uint32_t handle, const uint8_t *url, uint16_t urlLen);
32119e95205Sopenharmony_ci
32219e95205Sopenharmony_ci/**
32319e95205Sopenharmony_ci * @brief Add ServiceName Attribute to record. The ServiceName attribute is a string containing the name of
32419e95205Sopenharmony_ci *        the service represented by a service record. Refer to charter 5.1.15 of Core 5.0.
32519e95205Sopenharmony_ci *
32619e95205Sopenharmony_ci * @param handle          Service record handle.
32719e95205Sopenharmony_ci * @param baseAttributeId The attribute ID base (default 0x0100).
32819e95205Sopenharmony_ci * @param name            The service name.
32919e95205Sopenharmony_ci * @param nameLen         The length of name.
33019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
33119e95205Sopenharmony_ci */
33219e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceName(uint32_t handle, uint16_t baseAttributeId, const char *name, uint16_t nameLen);
33319e95205Sopenharmony_ci
33419e95205Sopenharmony_ci/**
33519e95205Sopenharmony_ci * @brief Add ServiceDescription Attribute to record. The ServiceDescription attribute is a string
33619e95205Sopenharmony_ci *        containing a brief description of the service. Refer to charter 5.1.16 of Core 5.0.
33719e95205Sopenharmony_ci *
33819e95205Sopenharmony_ci * @param handle          Service record handle.
33919e95205Sopenharmony_ci * @param baseAttributeId The attribute ID base (default 0x0100).
34019e95205Sopenharmony_ci * @param description     A brief description of the service.
34119e95205Sopenharmony_ci * @param descriptionLen  The length of description.
34219e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
34319e95205Sopenharmony_ci */
34419e95205Sopenharmony_ciint BTSTACK_API SDP_AddServiceDescription(
34519e95205Sopenharmony_ci    uint32_t handle, uint16_t baseAttributeId, const char *description, uint16_t descriptionLen);
34619e95205Sopenharmony_ci
34719e95205Sopenharmony_ci/**
34819e95205Sopenharmony_ci * @brief Add ProviderName Attribute to record. This ProviderName attribute is a string containing the name of
34919e95205Sopenharmony_ci *        the person or organization providing the service. Refer to charter 5.1.17 of Core 5.0.
35019e95205Sopenharmony_ci *
35119e95205Sopenharmony_ci * @param handle          Service record handle.
35219e95205Sopenharmony_ci * @param baseAttributeId The attribute ID base (default 0x0100).
35319e95205Sopenharmony_ci * @param name            The name of the person or organization providing the service.
35419e95205Sopenharmony_ci * @param nameLen         The length of name.
35519e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
35619e95205Sopenharmony_ci */
35719e95205Sopenharmony_ciint BTSTACK_API SDP_AddProviderName(uint32_t handle, uint16_t baseAttributeId, const char *name, uint16_t nameLen);
35819e95205Sopenharmony_ci
35919e95205Sopenharmony_ci/**
36019e95205Sopenharmony_ci * @brief Add attribute undefined in Core 5.0 specification. Refer to charter 2.2 of Core 5.0.
36119e95205Sopenharmony_ci *
36219e95205Sopenharmony_ci * @param handle               Service record handle.
36319e95205Sopenharmony_ci * @param attributeId          Attribute undefined in Core 5.0.
36419e95205Sopenharmony_ci * @param type                 The type of attribute value.
36519e95205Sopenharmony_ci * @param attributeValue       Attribute value.
36619e95205Sopenharmony_ci * @param attributeValueLength The length of attribute value.
36719e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
36819e95205Sopenharmony_ci */
36919e95205Sopenharmony_ciint BTSTACK_API SDP_AddAttribute(
37019e95205Sopenharmony_ci    uint32_t handle, uint16_t attributeId, SdpDataType type, void *attributeValue, uint16_t attributeValueLength);
37119e95205Sopenharmony_ci
37219e95205Sopenharmony_ci/**
37319e95205Sopenharmony_ci * @brief Add attribute, which value is sequence, undefined in Core 5.0 specification. Refer to charter 2.2 of
37419e95205Sopenharmony_ci * Core 5.0.
37519e95205Sopenharmony_ci *
37619e95205Sopenharmony_ci * @param handle               Service record handle.
37719e95205Sopenharmony_ci * @param attributeId          Attribute undefined in Core 5.0.
37819e95205Sopenharmony_ci * @param attributeValue       Attribute value.
37919e95205Sopenharmony_ci * @param attributeValueLength The length of attribute value.
38019e95205Sopenharmony_ci * @return Returns <b>BT_SUCCESS</b> if the operation is successful, otherwise the operation fails.
38119e95205Sopenharmony_ci */
38219e95205Sopenharmony_ciint BTSTACK_API SDP_AddSequenceAttribute(
38319e95205Sopenharmony_ci    uint32_t handle, uint16_t attributeId, const uint8_t *attributeValue, uint16_t attributeValueLength);
38419e95205Sopenharmony_ci
38519e95205Sopenharmony_ci/**
38619e95205Sopenharmony_ci *  @brief Type of AttributeID list.
38719e95205Sopenharmony_ci */
38819e95205Sopenharmony_citypedef enum {
38919e95205Sopenharmony_ci    SDP_TYPE_LIST,
39019e95205Sopenharmony_ci    SDP_TYPE_RANGE,
39119e95205Sopenharmony_ci} SdpAttributeIdListType;
39219e95205Sopenharmony_ci
39319e95205Sopenharmony_ci/**
39419e95205Sopenharmony_ci *  @brief Uuid list.
39519e95205Sopenharmony_ci */
39619e95205Sopenharmony_citypedef struct {
39719e95205Sopenharmony_ci    uint16_t uuidNum;
39819e95205Sopenharmony_ci    BtUuid *uuid;
39919e95205Sopenharmony_ci} SdpUuid;
40019e95205Sopenharmony_ci
40119e95205Sopenharmony_ci/**
40219e95205Sopenharmony_ci *  @brief The list is either some attribute IDs or a range of attribute IDs.
40319e95205Sopenharmony_ci */
40419e95205Sopenharmony_citypedef struct {
40519e95205Sopenharmony_ci    SdpAttributeIdListType type;
40619e95205Sopenharmony_ci    union {
40719e95205Sopenharmony_ci        struct {
40819e95205Sopenharmony_ci            uint16_t attributeIdNumber;
40919e95205Sopenharmony_ci            uint16_t attributeId[SDP_ATTRIBUTE_ID_LIST_MAX_COUNT];
41019e95205Sopenharmony_ci        } attributeIdList;
41119e95205Sopenharmony_ci
41219e95205Sopenharmony_ci        struct {
41319e95205Sopenharmony_ci            uint16_t start;
41419e95205Sopenharmony_ci            uint16_t end;
41519e95205Sopenharmony_ci        } attributeIdRange;
41619e95205Sopenharmony_ci    };
41719e95205Sopenharmony_ci} SdpAttributeIdList;
41819e95205Sopenharmony_ci
41919e95205Sopenharmony_ci/**
42019e95205Sopenharmony_ci *  @brief Get undefined attribute in Core 5.0.
42119e95205Sopenharmony_ci */
42219e95205Sopenharmony_citypedef struct {
42319e95205Sopenharmony_ci    uint16_t attributeId;
42419e95205Sopenharmony_ci    SdpDataType type;
42519e95205Sopenharmony_ci    uint16_t attributeValueLength;
42619e95205Sopenharmony_ci    void *attributeValue;
42719e95205Sopenharmony_ci} SdpAttribute;
42819e95205Sopenharmony_ci
42919e95205Sopenharmony_ci/**
43019e95205Sopenharmony_ci *  @brief Add undefined attribute in Core 5.0, which value is sequence.
43119e95205Sopenharmony_ci */
43219e95205Sopenharmony_citypedef struct {
43319e95205Sopenharmony_ci    uint16_t attributeId;
43419e95205Sopenharmony_ci    uint16_t attributeValueLength;
43519e95205Sopenharmony_ci    uint8_t *attributeValue;
43619e95205Sopenharmony_ci} SdpSequenceAttribute;
43719e95205Sopenharmony_ci
43819e95205Sopenharmony_ci/**
43919e95205Sopenharmony_ci *  @brief Callback all attribute value.
44019e95205Sopenharmony_ci */
44119e95205Sopenharmony_citypedef struct {
44219e95205Sopenharmony_ci    uint32_t handle;
44319e95205Sopenharmony_ci
44419e95205Sopenharmony_ci    uint16_t classIdNumber;
44519e95205Sopenharmony_ci    BtUuid *classId;
44619e95205Sopenharmony_ci
44719e95205Sopenharmony_ci    uint32_t state;
44819e95205Sopenharmony_ci    BtUuid serviceId;
44919e95205Sopenharmony_ci
45019e95205Sopenharmony_ci    uint16_t descriptorNumber;
45119e95205Sopenharmony_ci    SdpProtocolDescriptor *descriptor;
45219e95205Sopenharmony_ci
45319e95205Sopenharmony_ci    uint16_t descriptorListNumber;
45419e95205Sopenharmony_ci    SdpAdditionalProtocolDescriptor *descriptorList;
45519e95205Sopenharmony_ci
45619e95205Sopenharmony_ci    uint16_t browseUuidNumber;
45719e95205Sopenharmony_ci    BtUuid *browseUuid;
45819e95205Sopenharmony_ci
45919e95205Sopenharmony_ci    uint16_t baseAttributeIdNumber;
46019e95205Sopenharmony_ci    SdpLanguageBaseAttributeId *baseAttributeId;
46119e95205Sopenharmony_ci
46219e95205Sopenharmony_ci    uint32_t serviceInfoTimeToLive;
46319e95205Sopenharmony_ci    uint8_t serviceAvailability;
46419e95205Sopenharmony_ci
46519e95205Sopenharmony_ci    uint16_t profileDescriptorNumber;
46619e95205Sopenharmony_ci    SdpProfileDescriptor *profileDescriptor;
46719e95205Sopenharmony_ci
46819e95205Sopenharmony_ci    char *documentationUrl;
46919e95205Sopenharmony_ci    char *clientExecutableUrl;
47019e95205Sopenharmony_ci    char *iconUrl;
47119e95205Sopenharmony_ci
47219e95205Sopenharmony_ci    char *serviceName;
47319e95205Sopenharmony_ci    char *serviceDescription;
47419e95205Sopenharmony_ci    char *providerName;
47519e95205Sopenharmony_ci
47619e95205Sopenharmony_ci    uint16_t attributeNumber;
47719e95205Sopenharmony_ci    SdpAttribute *attribute;
47819e95205Sopenharmony_ci
47919e95205Sopenharmony_ci    uint16_t sequenceAttributeNumber;
48019e95205Sopenharmony_ci    SdpSequenceAttribute *sequenceAttribute;
48119e95205Sopenharmony_ci} SdpService;
48219e95205Sopenharmony_ci
48319e95205Sopenharmony_ci/**
48419e95205Sopenharmony_ci * @brief The SDP client generates an SDP_ServiceSearchRequest to locate service records that match the service
48519e95205Sopenharmony_ci *        search pattern given as the first parameter of the PDU. Refer to charter 4.5.1 and 4.5.2 of Core 5.0.
48619e95205Sopenharmony_ci *
48719e95205Sopenharmony_ci * @param addr      The remote bluetooth device address.
48819e95205Sopenharmony_ci * @param uuidArray The list of uuids.
48919e95205Sopenharmony_ci * @param uuidNum   The number of uuids.
49019e95205Sopenharmony_ci * @param context   The context from upper layer.
49119e95205Sopenharmony_ci * @param ServiceSearchCb callback.
49219e95205Sopenharmony_ci * @return Returns <b>BT_NO_ERROE</b> if the operation is successful; returns <b>false</b> if the operation fails.
49319e95205Sopenharmony_ci */
49419e95205Sopenharmony_ciint BTSTACK_API SDP_ServiceSearch(const BtAddr *addr, const SdpUuid *uuidArray, void *context,
49519e95205Sopenharmony_ci    void (*serviceSearchCb)(const BtAddr *addr, const uint32_t *handleArray, uint16_t handleNum, void *context));
49619e95205Sopenharmony_ci
49719e95205Sopenharmony_ci/**
49819e95205Sopenharmony_ci * @brief The SDP client generates an SDP_ServiceAttributeRequest to retrieve specified attribute values
49919e95205Sopenharmony_ci *        from a specific service record. Refer to charter 4.6.1 and 4.6.2 of Core 5.0.
50019e95205Sopenharmony_ci
50119e95205Sopenharmony_ci * @param addr   The remote bluetooth device address.
50219e95205Sopenharmony_ci * @param handle A service record handle.
50319e95205Sopenharmony_ci * @param attributeIdList The list is either an attribute ID or a range of attribute IDs. Note that
50419e95205Sopenharmony_ci *                        all attributes can be requested by specifying a range of 0x0000-0xFFFF.
50519e95205Sopenharmony_ci * @param context The context from upper layer.
50619e95205Sopenharmony_ci * @param ServiceAttributeCb callback
50719e95205Sopenharmony_ci * @return Returns <b>BT_NO_ERROE</b> if the operation is successful; returns <b>false</b> if the operation fails.
50819e95205Sopenharmony_ci */
50919e95205Sopenharmony_ciint BTSTACK_API SDP_ServiceAttribute(const BtAddr *addr, uint32_t handle, SdpAttributeIdList attributeIdList,
51019e95205Sopenharmony_ci    void *context, void (*serviceAttributeCb)(const BtAddr *addr, const SdpService *service, void *context));
51119e95205Sopenharmony_ci
51219e95205Sopenharmony_ci/**
51319e95205Sopenharmony_ci * @brief The SDP_ServiceSearchAttributeRequest transaction combines the capabilities of the SDP_ServiceSearchRequest
51419e95205Sopenharmony_ci *        and the SDP_ServiceAttributeRequest into a single request. Refer to charter 4.7.1 and 4.7.2 of Core 5.0.
51519e95205Sopenharmony_ci *
51619e95205Sopenharmony_ci * @param addr      The remote bluetooth device address.
51719e95205Sopenharmony_ci * @param uuidArray The list of uuids.
51819e95205Sopenharmony_ci * @param attributeIdList The list is either an attribute ID or a range of attribute IDs. Note that
51919e95205Sopenharmony_ci *                        all attributes can be requested by specifying a range of 0x0000-0xFFFF.
52019e95205Sopenharmony_ci * @param context   The context from upper layer.
52119e95205Sopenharmony_ci * @param ServiceSearchAttributeCb callback.
52219e95205Sopenharmony_ci * @return Returns <b>BT_NO_ERROE</b> if the operation is successful; returns <b>false</b> if the operation fails.
52319e95205Sopenharmony_ci */
52419e95205Sopenharmony_ciint BTSTACK_API SDP_ServiceSearchAttribute(const BtAddr *addr, const SdpUuid *uuidArray,
52519e95205Sopenharmony_ci    SdpAttributeIdList attributeIdList, void *context,
52619e95205Sopenharmony_ci    void (*searchAttributeCb)(const BtAddr *addr, const SdpService *serviceArray, uint16_t serviceNum, void *context));
52719e95205Sopenharmony_ci
52819e95205Sopenharmony_ci/**
52919e95205Sopenharmony_ci * @brief Browse all record handles of remote device. Refer to charter 2.6 of Core 5.0.
53019e95205Sopenharmony_ci *
53119e95205Sopenharmony_ci * @param addr    The remote bluetooth device address.
53219e95205Sopenharmony_ci * @param context The context from upper layer.
53319e95205Sopenharmony_ci * @param ServiceBrowseCb callback.
53419e95205Sopenharmony_ci * @return Returns <b>BT_NO_ERROE</b> if the operation is successful; returns <b>false</b> if the operation fails.
53519e95205Sopenharmony_ci */
53619e95205Sopenharmony_ciint BTSTACK_API SDP_ServiceBrowse(const BtAddr *addr, void *context,
53719e95205Sopenharmony_ci    void (*ServiceBrowseCb)(const BtAddr *addr, const uint32_t *handleArray, uint16_t handleNum, void *context));
53819e95205Sopenharmony_ci
53919e95205Sopenharmony_ci#ifdef __cplusplus
54019e95205Sopenharmony_ci}
54119e95205Sopenharmony_ci#endif
54219e95205Sopenharmony_ci
54319e95205Sopenharmony_ci#endif  // SDP_H