****************************************************************************/
tBTA_SDP_CB bta_sdp_cb;
-
-/* state machine action enumeration list */
-#define BTA_SDP_NUM_ACTIONS (BTA_SDP_MAX_INT_EVT & 0x00ff)
-
-/* type for action functions */
-typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG* p_data);
-
-/* action function list */
-const tBTA_SDP_ACTION bta_sdp_action[] = {
- bta_sdp_enable, /* BTA_SDP_API_ENABLE_EVT */
- bta_sdp_search, /* BTA_SDP_API_SEARCH_EVT */
- bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */
- bta_sdp_remove_record, /* BTA_SDP_API_REMOVE_RECORD_USER_EVT */
-};
-
-/*******************************************************************************
- * Function bta_sdp_sm_execute
- *
- * Description State machine event handling function for SDP search
- *
- * Returns void
- ******************************************************************************/
-bool bta_sdp_sm_execute(BT_HDR* p_msg) {
- if (p_msg == NULL) return false;
-
- bool ret = false;
- uint16_t action = (p_msg->event & 0x00ff);
-
- /* execute action functions */
- if (action < BTA_SDP_NUM_ACTIONS) {
- (*bta_sdp_action[action])((tBTA_SDP_MSG*)p_msg);
- ret = true;
- }
-
- return (ret);
-}
* Returns void
*
******************************************************************************/
-void bta_sdp_enable(tBTA_SDP_MSG* p_data) {
+void bta_sdp_enable(tBTA_SDP_API_ENABLE* p_data) {
APPL_TRACE_DEBUG("%s in, sdp_active:%d", __func__, bta_sdp_cb.sdp_active);
tBTA_SDP_STATUS status = BTA_SDP_SUCCESS;
- bta_sdp_cb.p_dm_cback = p_data->enable.p_cback;
+ bta_sdp_cb.p_dm_cback = p_data->p_cback;
tBTA_SDP bta_sdp;
bta_sdp.status = status;
bta_sdp_cb.p_dm_cback(BTA_SDP_ENABLE_EVT, &bta_sdp, NULL);
+ osi_free(p_data);
}
/*******************************************************************************
* Returns void
*
******************************************************************************/
-void bta_sdp_search(tBTA_SDP_MSG* p_data) {
+void bta_sdp_search(tBTA_SDP_API_SEARCH* p_data) {
if (p_data == NULL) {
APPL_TRACE_DEBUG("SDP control block handle is null");
return;
APPL_TRACE_DEBUG("%s in, sdp_active:%d", __func__, bta_sdp_cb.sdp_active);
- const Uuid& uuid = p_data->get_search.uuid;
+ const Uuid& uuid = p_data->uuid;
if (bta_sdp_cb.sdp_active != BTA_SDP_ACTIVE_NONE) {
/* SDP is still in progress */
status = BTA_SDP_BUSY;
tBTA_SDP_SEARCH_COMP result;
memset(&result, 0, sizeof(result));
result.uuid = uuid;
- result.remote_addr = p_data->get_search.bd_addr;
+ result.remote_addr = p_data->bd_addr;
result.status = status;
tBTA_SDP bta_sdp;
bta_sdp.sdp_search_comp = result;
bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, &bta_sdp, NULL);
}
+ osi_free(p_data);
return;
}
bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_YES;
- bta_sdp_cb.remote_addr = p_data->get_search.bd_addr;
+ bta_sdp_cb.remote_addr = p_data->bd_addr;
/* initialize the search for the uuid */
APPL_TRACE_DEBUG("%s init discovery with UUID: %s", __func__,
Uuid* bta_sdp_search_uuid = (Uuid*)osi_malloc(sizeof(Uuid));
*bta_sdp_search_uuid = uuid;
if (!SDP_ServiceSearchAttributeRequest2(
- p_data->get_search.bd_addr, p_bta_sdp_cfg->p_sdp_db,
- bta_sdp_search_cback, (void*)bta_sdp_search_uuid)) {
+ p_data->bd_addr, p_bta_sdp_cfg->p_sdp_db, bta_sdp_search_cback,
+ (void*)bta_sdp_search_uuid)) {
bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;
/* failed to start SDP. report the failure right away */
tBTA_SDP_SEARCH_COMP result;
memset(&result, 0, sizeof(result));
result.uuid = uuid;
- result.remote_addr = p_data->get_search.bd_addr;
+ result.remote_addr = p_data->bd_addr;
result.status = status;
tBTA_SDP bta_sdp;
bta_sdp.sdp_search_comp = result;
/*
else report the result when the cback is called
*/
+ osi_free(p_data);
}
/*******************************************************************************
* Returns void
*
******************************************************************************/
-void bta_sdp_create_record(tBTA_SDP_MSG* p_data) {
- APPL_TRACE_DEBUG("%s() event: %d", __func__, p_data->record.hdr.event);
+void bta_sdp_create_record(tBTA_SDP_API_RECORD_USER* p_data) {
if (bta_sdp_cb.p_dm_cback)
bta_sdp_cb.p_dm_cback(BTA_SDP_CREATE_RECORD_USER_EVT, NULL,
- p_data->record.user_data);
+ p_data->user_data);
+ osi_free(p_data);
}
/*******************************************************************************
* Returns void
*
******************************************************************************/
-void bta_sdp_remove_record(tBTA_SDP_MSG* p_data) {
- APPL_TRACE_DEBUG("%s() event: %d", __func__, p_data->record.hdr.event);
+void bta_sdp_remove_record(tBTA_SDP_API_RECORD_USER* p_data) {
if (bta_sdp_cb.p_dm_cback)
bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, NULL,
- p_data->record.user_data);
+ p_data->user_data);
+ osi_free(p_data);
}
#include "bta_sys.h"
#include "port_api.h"
#include "sdp_api.h"
+#include "stack/include/btu.h"
/*****************************************************************************
* Constants
****************************************************************************/
-static const tBTA_SYS_REG bta_sdp_reg = {bta_sdp_sm_execute, NULL};
-
/*******************************************************************************
*
* Function BTA_SdpEnable
tBTA_SDP_STATUS status = BTA_SDP_FAILURE;
APPL_TRACE_API(__func__);
- if (p_cback && !bta_sys_is_register(BTA_ID_SDP)) {
+ if (p_cback) {
memset(&bta_sdp_cb, 0, sizeof(tBTA_SDP_CB));
- /* register with BTA system manager */
- bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
-
if (p_cback) {
tBTA_SDP_API_ENABLE* p_buf =
(tBTA_SDP_API_ENABLE*)osi_malloc(sizeof(tBTA_SDP_API_ENABLE));
p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
- bta_sys_sendmsg(p_buf);
+ do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_enable, p_buf));
status = BTA_SDP_SUCCESS;
}
}
p_msg->bd_addr = bd_addr;
p_msg->uuid = uuid;
- bta_sys_sendmsg(p_msg);
+ do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_search, p_msg));
return BTA_SDP_SUCCESS;
}
p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
p_msg->user_data = user_data;
- bta_sys_sendmsg(p_msg);
+ do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_create_record, p_msg));
return BTA_SDP_SUCCESS;
}
p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
p_msg->user_data = user_data;
- bta_sys_sendmsg(p_msg);
+ do_in_main_thread(FROM_HERE, base::Bind(bta_sdp_remove_record, p_msg));
return BTA_SDP_SUCCESS;
}