1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 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 19 /****************************************************************************** 20 * 21 * This is the public interface file for the BTA SDP I/F 22 * 23 ******************************************************************************/ 24 #ifndef BTA_SDP_API_H 25 #define BTA_SDP_API_H 26 27 #include "bt_sdp.h" 28 #include "common/bt_target.h" 29 #include "stack/bt_types.h" 30 #include "bta/bta_api.h" 31 #include "stack/btm_api.h" 32 33 #if (SDP_INCLUDED == TRUE) 34 /* status values */ 35 #define BTA_SDP_SUCCESS 0 /* Successful operation. */ 36 #define BTA_SDP_FAILURE 1 /* Generic failure. */ 37 #define BTA_SDP_BUSY 2 /* Temporarily can not handle this request. */ 38 39 typedef UINT8 tBTA_SDP_STATUS; 40 41 /* SDP I/F callback events */ 42 /* events received by tBTA_SDP_DM_CBACK */ 43 #define BTA_SDP_ENABLE_EVT 0 /* SDP service enabled */ 44 #define BTA_SDP_DISABLE_EVT 1 /* SDP service disenabled */ 45 #define BTA_SDP_SEARCH_EVT 2 /* SDP search started */ 46 #define BTA_SDP_SEARCH_COMP_EVT 3 /* SDP search complete */ 47 #define BTA_SDP_CREATE_RECORD_USER_EVT 4 /* SDP create record complete */ 48 #define BTA_SDP_REMOVE_RECORD_USER_EVT 5 /* SDP remove record complete */ 49 #define BTA_SDP_MAX_EVT 6 /* max number of SDP events */ 50 51 #define BTA_SDP_MAX_RECORDS 15 52 53 typedef UINT16 tBTA_SDP_EVT; 54 55 /* data associated with BTA_SDP_DISCOVERY_COMP_EVT */ 56 typedef struct { 57 tBTA_SDP_STATUS status; 58 BD_ADDR remote_addr; 59 tBT_UUID uuid; 60 int record_count; 61 bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS]; 62 } tBTA_SDP_SEARCH_COMP; 63 64 /* data associated with BTA_SDP_CREATE_RECORD_USER_EVT */ 65 typedef struct { 66 tBTA_SDP_STATUS status; 67 int handle; 68 } tBTA_SDP_CREATE_RECORD_USER; 69 70 /* data associated with BTA_SDP_REMOVE_RECORD_USER_EVT */ 71 typedef struct { 72 tBTA_SDP_STATUS status; 73 int handle; 74 } tBTA_SDP_REMOVE_RECORD_USER; 75 76 typedef union { 77 tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */ 78 tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */ 79 tBTA_SDP_CREATE_RECORD_USER sdp_create_record; /* BTA_SDP_CREATE_RECORD_USER_EVT */ 80 tBTA_SDP_REMOVE_RECORD_USER sdp_remove_record; /* BTA_SDP_REMOVE_RECORD_USER_EVT */ 81 } tBTA_SDP; 82 83 /* SDP DM Interface callback */ 84 typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *user_data); 85 86 /* MCE configuration structure */ 87 typedef struct { 88 UINT16 sdp_raw_size; /* The size of p_sdp_raw_data */ 89 UINT16 sdp_db_size; /* The size of p_sdp_db */ 90 #if (SDP_INCLUDED == TRUE) 91 UINT8 *p_sdp_raw_data; /* The data buffer to keep raw data */ 92 tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ 93 #endif ///SDP_INCLUDED == TRUE 94 } tBTA_SDP_CFG; 95 96 #ifdef __cplusplus 97 extern "C" 98 { 99 #endif 100 /******************************************************************************* 101 ** 102 ** Function BTA_SdpEnable 103 ** 104 ** Description Enable the SDP I/F service. When the enable 105 ** operation is complete the callback function will be 106 ** called with a BTA_SDP_ENABLE_EVT. This function must 107 ** be called before other functions in the MCE API are 108 ** called. 109 ** 110 ** Returns BTA_SDP_SUCCESS if successful. 111 ** BTA_SDP_FAIL if internal failure. 112 ** 113 *******************************************************************************/ 114 extern tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback); 115 116 /******************************************************************************* 117 ** 118 ** Function BTA_SdpDisable 119 ** 120 ** Description This function is used to request a callback to perform disable 121 ** operation. The registered callback will be called with event 122 ** BTA_SDP_DISABLE_EVT. 123 ** 124 ** Returns BTA_SDP_SUCCESS, if the request is being processed. 125 ** BTA_SDP_FAILURE, otherwise. 126 ** 127 *******************************************************************************/ 128 extern tBTA_SDP_STATUS BTA_SdpDisable(void); 129 130 /******************************************************************************* 131 ** 132 ** Function BTA_SdpCleanup 133 ** 134 ** Description Cleanup the SDP search I/F service. 135 ** Free buffer for SDP configuration structure. 136 ** 137 ** Returns BTA_SDP_SUCCESS if successful. 138 ** BTA_SDP_FAIL if internal failure. 139 ** 140 *******************************************************************************/ 141 extern tBTA_SDP_STATUS BTA_SdpCleanup(void); 142 143 /******************************************************************************* 144 ** 145 ** Function BTA_SdpSearch 146 ** 147 ** Description Start a search for sdp records for a specific BD_ADDR with a 148 ** specific profile uuid. 149 ** When the search operation is completed, the callback function 150 ** will be called with a BTA_SDP_SEARCH_EVT. 151 ** Returns BTA_SDP_SUCCESS if successful. 152 ** BTA_SDP_FAIL if internal failure. 153 ** 154 *******************************************************************************/ 155 extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid); 156 157 /******************************************************************************* 158 ** 159 ** Function BTA_SdpCreateRecordByUser 160 ** 161 ** Description This function is used to request a callback to create a SDP 162 ** record. The registered callback will be called with event 163 ** BTA_SDP_CREATE_RECORD_USER_EVT. 164 ** 165 ** Returns BTA_SDP_SUCCESS, if the request is being processed. 166 ** BTA_SDP_FAILURE, otherwise. 167 ** 168 *******************************************************************************/ 169 extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data); 170 171 /******************************************************************************* 172 ** 173 ** Function BTA_SdpRemoveRecordByUser 174 ** 175 ** Description This function is used to request a callback to remove a SDP 176 ** record. The registered callback will be called with event 177 ** BTA_SDP_REMOVE_RECORD_USER_EVT. 178 ** 179 ** Returns BTA_SDP_SUCCESS, if the request is being processed. 180 ** BTA_SDP_FAILURE, otherwise. 181 ** 182 *******************************************************************************/ 183 extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data); 184 185 #ifdef __cplusplus 186 } 187 #endif 188 189 #endif ///SDP_INCLUDED == TRUE 190 191 #endif /* BTA_SDP_API_H */ 192