1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
24
25
33
34
35
36
37
38
39
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
74
75
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
114
115
116
117
118
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
219
220
221
222
223
224
/* ... */
/* ... */
#include "common/bt_target.h"
#include "bta/bta_api.h"
#include "bta/bta_sys.h"
#include "bta/bta_sdp_api.h"
#include "bta_sdp_int.h"
#include <string.h>
#include "osi/allocator.h"
#include "stack/sdp_api.h"8 includes
#if defined(BTA_SDP_INCLUDED) && (BTA_SDP_INCLUDED == TRUE)
/* ... */
static const tBTA_SYS_REG bta_sdp_reg = {
bta_sdp_sm_execute,
NULL
}{...};
/* ... */
tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback)
{
tBTA_SDP_STATUS status = BTA_SDP_FAILURE;
tBTA_SDP_API_ENABLE *p_buf;
APPL_TRACE_API("%s\n", __FUNCTION__);
#if BTA_DYNAMIC_MEMORY == TRUE
p_bta_sdp_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_sdp_cfg->sdp_db_size);
p_bta_sdp_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_sdp_cfg->sdp_raw_size);
if (p_bta_sdp_cfg->p_sdp_db == NULL || p_bta_sdp_cfg->p_sdp_raw_data == NULL) {
BTA_SdpCleanup();
return BTA_SDP_FAILURE;
}{...}
/* ... */#endif
if (p_cback && FALSE == bta_sys_is_register(BTA_ID_SDP)) {
memset(&bta_sdp_cb, 0, sizeof(tBTA_SDP_CB));
bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
if (p_cback &&
(p_buf = (tBTA_SDP_API_ENABLE *) osi_malloc(sizeof(tBTA_SDP_API_ENABLE))) != NULL) {
p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf);
status = BTA_SDP_SUCCESS;
}{...}
}{...}
return (status);
}{...}
/* ... */
tBTA_SDP_STATUS BTA_SdpDisable(void)
{
BT_HDR *p_buf = NULL;
tBTA_SDP_STATUS status = BTA_SDP_SUCCESS;
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR))) != NULL) {
p_buf->event = BTA_SDP_API_DISABLE_EVT;
bta_sys_sendmsg(p_buf);
status = BTA_SDP_FAILURE;
}{...}
return status;
}{...}
tBTA_SDP_STATUS BTA_SdpCleanup(void)
{
bta_sys_deregister(BTA_ID_SDP);
#if BTA_DYNAMIC_MEMORY == TRUE
if (p_bta_sdp_cfg->p_sdp_db) {
osi_free(p_bta_sdp_cfg->p_sdp_db);
p_bta_sdp_cfg->p_sdp_db = NULL;
}{...}
if (p_bta_sdp_cfg->p_sdp_raw_data) {
osi_free(p_bta_sdp_cfg->p_sdp_raw_data);
p_bta_sdp_cfg->p_sdp_raw_data = NULL;
}{...}
/* ... */#endif
return BTA_SDP_SUCCESS;
}{...}
/* ... */
tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
{
tBTA_SDP_STATUS ret = BTA_SDP_FAILURE;
tBTA_SDP_API_SEARCH *p_msg;
APPL_TRACE_API("%s\n", __FUNCTION__);
if ((p_msg = (tBTA_SDP_API_SEARCH *)osi_malloc(sizeof(tBTA_SDP_API_SEARCH))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
memcpy(&(p_msg->uuid), uuid, sizeof(tSDP_UUID));
bta_sys_sendmsg(p_msg);
ret = BTA_SDP_SUCCESS;
}{...}
return (ret);
}{...}
/* ... */
tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data)
{
tBTA_SDP_STATUS ret = BTA_SDP_FAILURE;
tBTA_SDP_API_RECORD_USER *p_msg;
APPL_TRACE_API("%s\n", __FUNCTION__);
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_malloc(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);
ret = BTA_SDP_SUCCESS;
}{...}
return (ret);
}{...}
/* ... */
tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data)
{
tBTA_SDP_STATUS ret = BTA_SDP_FAILURE;
tBTA_SDP_API_RECORD_USER *p_msg;
APPL_TRACE_API("%s\n", __FUNCTION__);
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)osi_malloc(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
p_msg->user_data = user_data;
bta_sys_sendmsg(p_msg);
ret = BTA_SDP_SUCCESS;
}{...}
return (ret);
}{...}
/* ... */
#endif