blob: 72ccd0ef453c5d699d288d18f0840f48b6f1c43a [file] [log] [blame]
The Android Open Source Project5738f832012-12-12 16:00:35 -08001/******************************************************************************
2 *
3 * Copyright (C) 1999-2012 Broadcom Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18#ifndef SDP_API_H
19#define SDP_API_H
20
21#include "bt_target.h"
22#include "sdpdefs.h"
23
24/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -080025 * Constants
26 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080027
28/* Success code and error codes */
Myles Watson911d1ae2016-11-28 16:44:40 -080029#define SDP_SUCCESS 0x0000
30#define SDP_INVALID_VERSION 0x0001
31#define SDP_INVALID_SERV_REC_HDL 0x0002
32#define SDP_INVALID_REQ_SYNTAX 0x0003
33#define SDP_INVALID_PDU_SIZE 0x0004
34#define SDP_INVALID_CONT_STATE 0x0005
35#define SDP_NO_RESOURCES 0x0006
36#define SDP_DI_REG_FAILED 0x0007
37#define SDP_DI_DISC_FAILED 0x0008
38#define SDP_NO_DI_RECORD_FOUND 0x0009
39#define SDP_ERR_ATTR_NOT_PRESENT 0x000A
40#define SDP_ILLEGAL_PARAMETER 0x000B
The Android Open Source Project5738f832012-12-12 16:00:35 -080041
Myles Watson911d1ae2016-11-28 16:44:40 -080042#define SDP_NO_RECS_MATCH 0xFFF0
43#define SDP_CONN_FAILED 0xFFF1
44#define SDP_CFG_FAILED 0xFFF2
45#define SDP_GENERIC_ERROR 0xFFF3
46#define SDP_DB_FULL 0xFFF4
47#define SDP_INVALID_PDU 0xFFF5
48#define SDP_SECURITY_ERR 0xFFF6
49#define SDP_CONN_REJECTED 0xFFF7
50#define SDP_CANCEL 0xFFF8
The Android Open Source Project5738f832012-12-12 16:00:35 -080051
The Android Open Source Project5738f832012-12-12 16:00:35 -080052/* Define the PSM that SDP uses */
Myles Watson911d1ae2016-11-28 16:44:40 -080053#define SDP_PSM 0x0001
The Android Open Source Project5738f832012-12-12 16:00:35 -080054
55/* Legacy #define to avoid code changes - SDP UUID is same as BT UUID */
Myles Watson911d1ae2016-11-28 16:44:40 -080056#define tSDP_UUID tBT_UUID
The Android Open Source Project5738f832012-12-12 16:00:35 -080057
58/* Masks for attr_value field of tSDP_DISC_ATTR */
Myles Watson911d1ae2016-11-28 16:44:40 -080059#define SDP_DISC_ATTR_LEN_MASK 0x0FFF
60#define SDP_DISC_ATTR_TYPE(len_type) ((len_type) >> 12)
61#define SDP_DISC_ATTR_LEN(len_type) ((len_type)&SDP_DISC_ATTR_LEN_MASK)
The Android Open Source Project5738f832012-12-12 16:00:35 -080062
63/* Maximum number of protocol list items (list_elem in tSDP_PROTOCOL_ELEM) */
Myles Watson911d1ae2016-11-28 16:44:40 -080064#define SDP_MAX_LIST_ELEMS 3
The Android Open Source Project5738f832012-12-12 16:00:35 -080065
66/*****************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -080067 * Type Definitions
68 ****************************************************************************/
The Android Open Source Project5738f832012-12-12 16:00:35 -080069
70/* Define a callback function for when discovery is complete. */
Myles Watson911d1ae2016-11-28 16:44:40 -080071typedef void(tSDP_DISC_CMPL_CB)(uint16_t result);
72typedef void(tSDP_DISC_CMPL_CB2)(uint16_t result, void* user_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -080073
Myles Watson911d1ae2016-11-28 16:44:40 -080074typedef struct {
Jakub Pawlowskia484a882017-06-24 17:30:18 -070075 RawAddress peer_addr;
Myles Watson911d1ae2016-11-28 16:44:40 -080076 uint16_t peer_mtu;
The Android Open Source Project5738f832012-12-12 16:00:35 -080077} tSDP_DR_OPEN;
78
Myles Watson911d1ae2016-11-28 16:44:40 -080079typedef struct {
80 uint8_t* p_data;
81 uint16_t data_len;
The Android Open Source Project5738f832012-12-12 16:00:35 -080082} tSDP_DR_DATA;
83
Myles Watson911d1ae2016-11-28 16:44:40 -080084typedef union {
85 tSDP_DR_OPEN open;
86 tSDP_DR_DATA data;
The Android Open Source Project5738f832012-12-12 16:00:35 -080087} tSDP_DATA;
88
89/* Define a callback function for when discovery result is received. */
Myles Watson911d1ae2016-11-28 16:44:40 -080090typedef void(tSDP_DISC_RES_CB)(uint16_t event, tSDP_DATA* p_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -080091
92/* Define a structure to hold the discovered service information. */
Myles Watson911d1ae2016-11-28 16:44:40 -080093typedef struct {
94 union {
95 uint8_t u8; /* 8-bit integer */
96 uint16_t u16; /* 16-bit integer */
97 uint32_t u32; /* 32-bit integer */
98 uint8_t array[4]; /* Variable length field */
99 struct t_sdp_disc_attr* p_sub_attr; /* Addr of first sub-attr (list)*/
100 } v;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800101
102} tSDP_DISC_ATVAL;
103
Myles Watson911d1ae2016-11-28 16:44:40 -0800104typedef struct t_sdp_disc_attr {
105 struct t_sdp_disc_attr* p_next_attr; /* Addr of next linked attr */
106 uint16_t attr_id; /* Attribute ID */
107 uint16_t attr_len_type; /* Length and type fields */
108 tSDP_DISC_ATVAL attr_value; /* Variable length entry data */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800109} tSDP_DISC_ATTR;
110
Myles Watson911d1ae2016-11-28 16:44:40 -0800111typedef struct t_sdp_disc_rec {
112 tSDP_DISC_ATTR* p_first_attr; /* First attribute of record */
113 struct t_sdp_disc_rec* p_next_rec; /* Addr of next linked record */
114 uint32_t time_read; /* The time the record was read */
Jakub Pawlowskia484a882017-06-24 17:30:18 -0700115 RawAddress remote_bd_addr; /* Remote BD address */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800116} tSDP_DISC_REC;
117
Myles Watson911d1ae2016-11-28 16:44:40 -0800118typedef struct {
119 uint32_t mem_size; /* Memory size of the DB */
120 uint32_t mem_free; /* Memory still available */
121 tSDP_DISC_REC* p_first_rec; /* Addr of first record in DB */
122 uint16_t num_uuid_filters; /* Number of UUIds to filter */
123 tSDP_UUID uuid_filters[SDP_MAX_UUID_FILTERS]; /* UUIDs to filter */
124 uint16_t num_attr_filters; /* Number of attribute filters */
125 uint16_t attr_filters[SDP_MAX_ATTR_FILTERS]; /* Attributes to filter */
126 uint8_t* p_free_mem; /* Pointer to free memory */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800127#if (SDP_RAW_DATA_INCLUDED == TRUE)
Myles Watson911d1ae2016-11-28 16:44:40 -0800128 uint8_t*
129 raw_data; /* Received record from server. allocated/released by client */
130 uint32_t raw_size; /* size of raw_data */
131 uint32_t raw_used; /* length of raw_data used */
The Android Open Source Project5738f832012-12-12 16:00:35 -0800132#endif
Myles Watson911d1ae2016-11-28 16:44:40 -0800133} tSDP_DISCOVERY_DB;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800134
135/* This structure is used to add protocol lists and find protocol elements */
Myles Watson911d1ae2016-11-28 16:44:40 -0800136typedef struct {
137 uint16_t protocol_uuid;
138 uint16_t num_params;
139 uint16_t params[SDP_MAX_PROTOCOL_PARAMS];
The Android Open Source Project5738f832012-12-12 16:00:35 -0800140} tSDP_PROTOCOL_ELEM;
141
Myles Watson911d1ae2016-11-28 16:44:40 -0800142typedef struct {
143 uint16_t num_elems;
144 tSDP_PROTOCOL_ELEM list_elem[SDP_MAX_LIST_ELEMS];
The Android Open Source Project5738f832012-12-12 16:00:35 -0800145} tSDP_PROTO_LIST_ELEM;
146
147/* Device Identification (DI) data structure
148*/
149/* Used to set the DI record */
Myles Watson911d1ae2016-11-28 16:44:40 -0800150typedef struct t_sdp_di_record {
151 uint16_t vendor;
152 uint16_t vendor_id_source;
153 uint16_t product;
154 uint16_t version;
155 bool primary_record;
156 char client_executable_url[SDP_MAX_ATTR_LEN]; /* optional */
157 char service_description[SDP_MAX_ATTR_LEN]; /* optional */
158 char documentation_url[SDP_MAX_ATTR_LEN]; /* optional */
159} tSDP_DI_RECORD;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800160
161/* Used to get the DI record */
Myles Watson911d1ae2016-11-28 16:44:40 -0800162typedef struct t_sdp_di_get_record {
163 uint16_t spec_id;
164 tSDP_DI_RECORD rec;
165} tSDP_DI_GET_RECORD;
The Android Open Source Project5738f832012-12-12 16:00:35 -0800166
The Android Open Source Project5738f832012-12-12 16:00:35 -0800167/* API into the SDP layer for service discovery. */
168
169/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800170 *
171 * Function SDP_InitDiscoveryDb
172 *
173 * Description This function is called to initialize a discovery database.
174 *
175 * Returns true if successful, false if one or more parameters are bad
176 *
177 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800178bool SDP_InitDiscoveryDb(tSDP_DISCOVERY_DB* p_db, uint32_t len,
179 uint16_t num_uuid, tSDP_UUID* p_uuid_list,
180 uint16_t num_attr, uint16_t* p_attr_list);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800181
182/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800183 *
184 * Function SDP_CancelServiceSearch
185 *
186 * Description This function cancels an active query to an SDP server.
187 *
Myles Watson9ca07092016-11-28 16:41:53 -0800188 * Returns true if discovery cancelled, false if a matching activity is
189 * not found.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800190 *
191 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800192bool SDP_CancelServiceSearch(tSDP_DISCOVERY_DB* p_db);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800193
194/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800195 *
196 * Function SDP_ServiceSearchRequest
197 *
198 * Description This function queries an SDP server for information.
199 *
200 * Returns true if discovery started, false if failed.
201 *
202 ******************************************************************************/
Jakub Pawlowskia484a882017-06-24 17:30:18 -0700203bool SDP_ServiceSearchRequest(const RawAddress& p_bd_addr,
Jakub Pawlowski135b7f62017-06-16 10:00:46 -0700204 tSDP_DISCOVERY_DB* p_db, tSDP_DISC_CMPL_CB* p_cb);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800205
206/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800207 *
208 * Function SDP_ServiceSearchAttributeRequest
209 *
210 * Description This function queries an SDP server for information.
211 *
212 * The difference between this API function and the function
213 * SDP_ServiceSearchRequest is that this one does a
214 * combined ServiceSearchAttributeRequest SDP function.
215 *
216 * Returns true if discovery started, false if failed.
217 *
218 ******************************************************************************/
Jakub Pawlowskia484a882017-06-24 17:30:18 -0700219bool SDP_ServiceSearchAttributeRequest(const RawAddress& p_bd_addr,
Myles Watson911d1ae2016-11-28 16:44:40 -0800220 tSDP_DISCOVERY_DB* p_db,
221 tSDP_DISC_CMPL_CB* p_cb);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800222
223/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800224 *
225 * Function SDP_ServiceSearchAttributeRequest2
226 *
227 * Description This function queries an SDP server for information.
228 *
229 * The difference between this API function and the function
230 * SDP_ServiceSearchRequest is that this one does a
231 * combined ServiceSearchAttributeRequest SDP function with the
232 * user data piggyback
233 *
234 * Returns true if discovery started, false if failed.
235 *
236 ******************************************************************************/
Jakub Pawlowskia484a882017-06-24 17:30:18 -0700237bool SDP_ServiceSearchAttributeRequest2(const RawAddress& p_bd_addr,
Myles Watson911d1ae2016-11-28 16:44:40 -0800238 tSDP_DISCOVERY_DB* p_db,
239 tSDP_DISC_CMPL_CB2* p_cb,
240 void* user_data);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800241
242/* API of utilities to find data in the local discovery database */
243
244/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800245 *
246 * Function SDP_FindAttributeInDb
247 *
Myles Watson9ca07092016-11-28 16:41:53 -0800248 * Description This function queries an SDP database for a specific
249 * attribute. If the p_start_rec pointer is NULL, it looks from
250 * the beginning of the database, else it continues from the
251 * next record after p_start_rec.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800252 *
253 * Returns Pointer to matching record, or NULL
254 *
255 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800256tSDP_DISC_REC* SDP_FindAttributeInDb(tSDP_DISCOVERY_DB* p_db, uint16_t attr_id,
257 tSDP_DISC_REC* p_start_rec);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800258
259/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800260 *
261 * Function SDP_FindAttributeInRec
262 *
263 * Description This function searches an SDP discovery record for a
264 * specific attribute.
265 *
266 * Returns Pointer to matching attribute entry, or NULL
267 *
268 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800269tSDP_DISC_ATTR* SDP_FindAttributeInRec(tSDP_DISC_REC* p_rec, uint16_t attr_id);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800270
271/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800272 *
273 * Function SDP_FindServiceInDb
274 *
Myles Watson9ca07092016-11-28 16:41:53 -0800275 * Description This function queries an SDP database for a specific
276 * service. If the p_start_rec pointer is NULL, it looks from
277 * the beginning of the database, else it continues from the
278 * next record after p_start_rec.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800279 *
280 * Returns Pointer to record containing service class, or NULL
281 *
282 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800283tSDP_DISC_REC* SDP_FindServiceInDb(tSDP_DISCOVERY_DB* p_db,
284 uint16_t service_uuid,
285 tSDP_DISC_REC* p_start_rec);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800286
287/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800288 *
289 * Function SDP_FindServiceUUIDInDb
290 *
Myles Watson9ca07092016-11-28 16:41:53 -0800291 * Description This function queries an SDP database for a specific
292 * service. If the p_start_rec pointer is NULL, it looks from
293 * the beginning of the database, else it continues from the
294 * next record after p_start_rec.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800295 *
296 * NOTE the only difference between this function and the previous
297 * function "SDP_FindServiceInDb()" is that this function takes
298 * a tBT_UUID input.
299 *
300 * Returns Pointer to record containing service class, or NULL
301 *
302 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800303tSDP_DISC_REC* SDP_FindServiceUUIDInDb(tSDP_DISCOVERY_DB* p_db,
304 tBT_UUID* p_uuid,
305 tSDP_DISC_REC* p_start_rec);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800306
307/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800308 *
309 * Function SDP_FindServiceUUIDInRec_128bit
310 *
Myles Watson9ca07092016-11-28 16:41:53 -0800311 * Description Read the 128-bit service UUID within a record,
Myles Watsonee96a3c2016-11-23 14:49:54 -0800312 * if there is any.
313 *
314 * Parameters: p_rec - pointer to a SDP record.
315 * p_uuid - output parameter to save the UUID found.
316 *
317 * Returns true if found, otherwise false.
318 *
319 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800320bool SDP_FindServiceUUIDInRec_128bit(tSDP_DISC_REC* p_rec, tBT_UUID* p_uuid);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800321
322/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800323 *
324 * Function SDP_FindServiceInDb_128bit
325 *
Myles Watson9ca07092016-11-28 16:41:53 -0800326 * Description Query an SDP database for a specific service.
327 * If the p_start_rec pointer is NULL, look from the beginning
328 * of the database, else continue from the next record after
Myles Watsonee96a3c2016-11-23 14:49:54 -0800329 * p_start_rec.
330 *
331 * Returns Pointer to record containing service class, or NULL
332 *
333 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800334tSDP_DISC_REC* SDP_FindServiceInDb_128bit(tSDP_DISCOVERY_DB* p_db,
335 tSDP_DISC_REC* p_start_rec);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800336
337/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800338 *
339 * Function SDP_FindProtocolListElemInRec
340 *
341 * Description This function looks at a specific discovery record for a
342 * protocol list element.
343 *
344 * Returns true if found, false if not
345 * If found, the passed protocol list element is filled in.
346 *
347 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800348bool SDP_FindProtocolListElemInRec(tSDP_DISC_REC* p_rec, uint16_t layer_uuid,
349 tSDP_PROTOCOL_ELEM* p_elem);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800350
351/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800352 *
353 * Function SDP_FindAddProtoListsElemInRec
354 *
355 * Description This function looks at a specific discovery record for a
356 * protocol list element.
357 *
358 * Returns true if found, false if not
359 * If found, the passed protocol list element is filled in.
360 *
361 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800362bool SDP_FindAddProtoListsElemInRec(tSDP_DISC_REC* p_rec, uint16_t layer_uuid,
363 tSDP_PROTOCOL_ELEM* p_elem);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800364
365/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800366 *
367 * Function SDP_FindProfileVersionInRec
368 *
369 * Description This function looks at a specific discovery record for the
370 * Profile list descriptor, and pulls out the version number.
371 * The version number consists of an 8-bit major version and
372 * an 8-bit minor version.
373 *
374 * Returns true if found, false if not
Myles Watson9ca07092016-11-28 16:41:53 -0800375 * If found, the major and minor version numbers that were
376 * passed in are filled in.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800377 *
378 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800379bool SDP_FindProfileVersionInRec(tSDP_DISC_REC* p_rec, uint16_t profile_uuid,
380 uint16_t* p_version);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800381
382/* API into SDP for local service database updates */
383
384/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800385 *
386 * Function SDP_CreateRecord
387 *
388 * Description This function is called to create a record in the database.
389 * This would be through the SDP database maintenance API. The
390 * record is created empty, teh application should then call
391 * "add_attribute" to add the record's attributes.
392 *
393 * Returns Record handle if OK, else 0.
394 *
395 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800396uint32_t SDP_CreateRecord(void);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800397
398/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800399 *
400 * Function SDP_DeleteRecord
401 *
402 * Description This function is called to add a record (or all records)
403 * from the database. This would be through the SDP database
404 * maintenance API.
405 *
406 * If a record handle of 0 is passed, all records are deleted.
407 *
408 * Returns true if succeeded, else false
409 *
410 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800411bool SDP_DeleteRecord(uint32_t handle);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800412
413/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800414 *
415 * Function SDP_ReadRecord
416 *
417 * Description This function is called to get the raw data of the record
418 * with the given handle from the database.
419 *
420 * Returns -1, if the record is not found.
421 * Otherwise, the offset (0 or 1) to start of data in p_data.
422 *
423 * The size of data copied into p_data is in *p_data_len.
424 *
425 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800426int32_t SDP_ReadRecord(uint32_t handle, uint8_t* p_data, int32_t* p_data_len);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800427
428/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800429 *
430 * Function SDP_AddAttribute
431 *
432 * Description This function is called to add an attribute to a record.
433 * This would be through the SDP database maintenance API.
Myles Watson9ca07092016-11-28 16:41:53 -0800434 * If the attribute already exists in the record, it is
435 * replaced with the new value.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800436 *
437 * NOTE Attribute values must be passed as a Big Endian stream.
438 *
439 * Returns true if added OK, else false
440 *
441 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800442bool SDP_AddAttribute(uint32_t handle, uint16_t attr_id, uint8_t attr_type,
443 uint32_t attr_len, uint8_t* p_val);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800444
445/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800446 *
447 * Function SDP_AddSequence
448 *
449 * Description This function is called to add a sequence to a record.
450 * This would be through the SDP database maintenance API.
451 * If the sequence already exists in the record, it is replaced
452 * with the new sequence.
453 *
454 * NOTE Element values must be passed as a Big Endian stream.
455 *
456 * Returns true if added OK, else false
457 *
458 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800459bool SDP_AddSequence(uint32_t handle, uint16_t attr_id, uint16_t num_elem,
460 uint8_t type[], uint8_t len[], uint8_t* p_val[]);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800461
462/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800463 *
464 * Function SDP_AddUuidSequence
465 *
466 * Description This function is called to add a UUID sequence to a record.
467 * This would be through the SDP database maintenance API.
468 * If the sequence already exists in the record, it is replaced
469 * with the new sequence.
470 *
471 * Returns true if added OK, else false
472 *
473 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800474bool SDP_AddUuidSequence(uint32_t handle, uint16_t attr_id, uint16_t num_uuids,
475 uint16_t* p_uuids);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800476
477/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800478 *
479 * Function SDP_AddProtocolList
480 *
481 * Description This function is called to add a protocol descriptor list to
Myles Watson9ca07092016-11-28 16:41:53 -0800482 * a record. This would be through the SDP database
483 * maintenance API. If the protocol list already exists in the
484 * record, it is replaced with the new list.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800485 *
486 * Returns true if added OK, else false
487 *
488 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800489bool SDP_AddProtocolList(uint32_t handle, uint16_t num_elem,
490 tSDP_PROTOCOL_ELEM* p_elem_list);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800491
492/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800493 *
494 * Function SDP_AddAdditionProtoLists
495 *
496 * Description This function is called to add a protocol descriptor list to
Myles Watson9ca07092016-11-28 16:41:53 -0800497 * a record. This would be through the SDP database maintenance
498 * API. If the protocol list already exists in the record, it
499 * is replaced with the new list.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800500 *
501 * Returns true if added OK, else false
502 *
503 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800504bool SDP_AddAdditionProtoLists(uint32_t handle, uint16_t num_elem,
505 tSDP_PROTO_LIST_ELEM* p_proto_list);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800506
507/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800508 *
509 * Function SDP_AddProfileDescriptorList
510 *
511 * Description This function is called to add a profile descriptor list to
Myles Watson9ca07092016-11-28 16:41:53 -0800512 * a record. This would be through the SDP database maintenance
513 * API. If the version already exists in the record, it is
514 * replaced with the new one.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800515 *
516 * Returns true if added OK, else false
517 *
518 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800519bool SDP_AddProfileDescriptorList(uint32_t handle, uint16_t profile_uuid,
520 uint16_t version);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800521
The Android Open Source Project5738f832012-12-12 16:00:35 -0800522/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800523 *
524 * Function SDP_AddLanguageBaseAttrIDList
525 *
526 * Description This function is called to add a language base attr list to
Myles Watson9ca07092016-11-28 16:41:53 -0800527 * a record. This would be through the SDP database maintenance
528 * API. If the version already exists in the record, it is
529 * replaced with the new one.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800530 *
531 * Returns true if added OK, else false
532 *
533 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800534bool SDP_AddLanguageBaseAttrIDList(uint32_t handle, uint16_t lang,
535 uint16_t char_enc, uint16_t base_id);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800536
The Android Open Source Project5738f832012-12-12 16:00:35 -0800537/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800538 *
539 * Function SDP_AddServiceClassIdList
540 *
541 * Description This function is called to add a service list to a record.
542 * This would be through the SDP database maintenance API.
Myles Watson9ca07092016-11-28 16:41:53 -0800543 * If the service list already exists in the record, it is
544 * replaced with the new list.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800545 *
546 * Returns true if added OK, else false
547 *
548 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800549bool SDP_AddServiceClassIdList(uint32_t handle, uint16_t num_services,
550 uint16_t* p_service_uuids);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800551
The Android Open Source Project5738f832012-12-12 16:00:35 -0800552/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800553 *
554 * Function SDP_DeleteAttribute
555 *
Myles Watson9ca07092016-11-28 16:41:53 -0800556 * Description Delete an attribute from a record.
Myles Watsonee96a3c2016-11-23 14:49:54 -0800557 * This would be through the SDP database maintenance API.
558 *
559 * Returns true if deleted OK, else false if not found
560 *
561 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800562bool SDP_DeleteAttribute(uint32_t handle, uint16_t attr_id);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800563
564/* Device Identification APIs */
565
566/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800567 *
568 * Function SDP_SetLocalDiRecord
569 *
570 * Description This function adds a DI record to the local SDP database.
571 *
572 * Returns Returns SDP_SUCCESS if record added successfully, else error
573 *
574 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800575uint16_t SDP_SetLocalDiRecord(tSDP_DI_RECORD* device_info, uint32_t* p_handle);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800576
577/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800578 *
579 * Function SDP_DiDiscover
580 *
581 * Description This function queries a remote device for DI information.
582 *
583 * Returns SDP_SUCCESS if query started successfully, else error
584 *
585 ******************************************************************************/
Jakub Pawlowskia484a882017-06-24 17:30:18 -0700586uint16_t SDP_DiDiscover(const RawAddress& remote_device,
Jakub Pawlowski135b7f62017-06-16 10:00:46 -0700587 tSDP_DISCOVERY_DB* p_db, uint32_t len,
588 tSDP_DISC_CMPL_CB* p_cb);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800589
The Android Open Source Project5738f832012-12-12 16:00:35 -0800590/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800591 *
592 * Function SDP_GetNumDiRecords
593 *
594 * Description Searches specified database for DI records
595 *
596 * Returns number of DI records found
597 *
598 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800599uint8_t SDP_GetNumDiRecords(tSDP_DISCOVERY_DB* p_db);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800600
601/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800602 *
603 * Function SDP_GetDiRecord
604 *
605 * Description This function retrieves a remote device's DI record from
606 * the specified database.
607 *
608 * Returns SDP_SUCCESS if record retrieved, else error
609 *
610 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800611uint16_t SDP_GetDiRecord(uint8_t getRecordIndex,
612 tSDP_DI_GET_RECORD* device_info,
613 tSDP_DISCOVERY_DB* p_db);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800614
The Android Open Source Project5738f832012-12-12 16:00:35 -0800615/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800616 *
617 * Function SDP_SetTraceLevel
618 *
619 * Description This function sets the trace level for SDP. If called with
620 * a value of 0xFF, it simply reads the current trace level.
621 *
622 * Returns the new (current) trace level
623 *
624 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800625uint8_t SDP_SetTraceLevel(uint8_t new_level);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800626
627/*******************************************************************************
Myles Watsonee96a3c2016-11-23 14:49:54 -0800628 *
629 * Function SDP_FindServiceUUIDInRec
630 *
Myles Watson9ca07092016-11-28 16:41:53 -0800631 * Description Read the service UUID within a record,
Myles Watsonee96a3c2016-11-23 14:49:54 -0800632 * if there is any.
633 *
634 * Parameters: p_rec - pointer to a SDP record.
635 *
636 * Returns true if found, otherwise false.
637 *
638 ******************************************************************************/
Myles Watson911d1ae2016-11-28 16:44:40 -0800639bool SDP_FindServiceUUIDInRec(tSDP_DISC_REC* p_rec, tBT_UUID* p_uuid);
The Android Open Source Project5738f832012-12-12 16:00:35 -0800640
Pavlin Radoslavovb2a292b2016-10-14 19:34:48 -0700641// Converts UUID-16 to UUID-128 by including the base UUID.
642// |uuid16| is the 2-byte UUID to convert.
643// The result with the expanded 128-bit UUID is stored in |p_uuid128|.
644void sdpu_uuid16_to_uuid128(uint16_t uuid16, uint8_t* p_uuid128);
645
Myles Watson911d1ae2016-11-28 16:44:40 -0800646#endif /* SDP_API_H */