1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
/******************************************************************************
*
* Copyright 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
/******************************************************************************
*
* This is the implementation of the API for SDP search subsystem
*
******************************************************************************/
#include "bta/include/bta_sdp_api.h"
#include <base/bind.h>
#include <base/location.h>
#include "bt_target.h" // Must be first to define build configuration
#include "bta/sdp/bta_sdp_int.h"
#include "stack/include/btu.h" // do_in_main_thread
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"
/*****************************************************************************
* Constants
****************************************************************************/
/*******************************************************************************
*
* Function BTA_SdpEnable
*
* Description Enable the SDP search I/F service. When the enable
* operation is complete the callback function will be
* called with a BTA_SDP_ENABLE_EVT. This function must
* be called before other functions in the SDP search API are
* called.
*
* Returns BTA_SDP_SUCCESS if successful.
* BTA_SDP_FAIL if internal failure.
*
******************************************************************************/
tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK* p_cback) {
if (!p_cback) {
return BTA_SDP_FAILURE;
}
memset(&bta_sdp_cb, 0, sizeof(tBTA_SDP_CB));
do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_enable, p_cback));
return BTA_SDP_SUCCESS;
}
/*******************************************************************************
*
* Function BTA_SdpSearch
*
* Description This function performs service discovery for a specific
* service on given peer device. When the operation is
* completed the tBTA_SDP_DM_CBACK callback function will be
* called with a BTA_SDP_SEARCH_COMPLETE_EVT.
*
* Returns BTA_SDP_SUCCESS, if the request is being processed.
* BTA_SDP_FAILURE, otherwise.
*
******************************************************************************/
tBTA_SDP_STATUS BTA_SdpSearch(const RawAddress& bd_addr,
const bluetooth::Uuid& uuid) {
do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_search, bd_addr, uuid));
return BTA_SDP_SUCCESS;
}
/*******************************************************************************
*
* Function BTA_SdpCreateRecordByUser
*
* Description This function is used to request a callback to create a SDP
* record. The registered callback will be called with event
* BTA_SDP_CREATE_RECORD_USER_EVT.
*
* Returns BTA_SDP_SUCCESS, if the request is being processed.
* BTA_SDP_FAILURE, otherwise.
*
******************************************************************************/
tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data) {
do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_create_record, user_data));
return BTA_SDP_SUCCESS;
}
/*******************************************************************************
*
* Function BTA_SdpRemoveRecordByUser
*
* Description This function is used to request a callback to remove a SDP
* record. The registered callback will be called with event
* BTA_SDP_REMOVE_RECORD_USER_EVT.
*
* Returns BTA_SDP_SUCCESS, if the request is being processed.
* BTA_SDP_FAILURE, otherwise.
*
******************************************************************************/
tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void* user_data) {
do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_remove_record, user_data));
return BTA_SDP_SUCCESS;
}
|