components/bt: Fix warning when disable debug logs or in release mode and improve the code structure

This commit is contained in:
baohongde 2019-03-26 14:37:37 +08:00
parent bbdb236ab7
commit 5ede49ca4a
43 changed files with 423 additions and 238 deletions

View file

@ -1293,9 +1293,10 @@ void bta_av_setconfig_rsp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
/* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind. /* if SBC is used by the SNK as INT, discover req is not sent in bta_av_config_ind.
* call disc_res now */ * call disc_res now */
/* this is called in A2DP SRC path only, In case of SINK we don't need it */ /* this is called in A2DP SRC path only, In case of SINK we don't need it */
if (local_sep == AVDT_TSEP_SRC) if (local_sep == AVDT_TSEP_SRC) {
p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr, p_scb->p_cos->disc_res(p_scb->hndl, num, num, 0, p_scb->peer_addr,
UUID_SERVCLASS_AUDIO_SOURCE); UUID_SERVCLASS_AUDIO_SOURCE);
}
} else { } else {
/* we do not know the peer device and it is using non-SBC codec /* we do not know the peer device and it is using non-SBC codec
* we need to know all the SEPs on SNK */ * we need to know all the SEPs on SNK */

View file

@ -829,10 +829,11 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) { if (p_data->rc_msg.msg.pass.op_id == AVRC_ID_VENDOR) {
p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL; p_data->rc_msg.msg.hdr.ctype = BTA_AV_RSP_NOT_IMPL;
#if (AVRC_METADATA_INCLUDED == TRUE) #if (AVRC_METADATA_INCLUDED == TRUE)
if (p_cb->features & BTA_AV_FEAT_METADATA) if (p_cb->features & BTA_AV_FEAT_METADATA) {
p_data->rc_msg.msg.hdr.ctype = p_data->rc_msg.msg.hdr.ctype =
bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len, bta_av_group_navi_supported(p_data->rc_msg.msg.pass.pass_len,
p_data->rc_msg.msg.pass.p_pass_data, is_inquiry); p_data->rc_msg.msg.pass.p_pass_data, is_inquiry);
}
#endif #endif
} else { } else {
p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry); p_data->rc_msg.msg.hdr.ctype = bta_av_op_supported(p_data->rc_msg.msg.pass.op_id, is_inquiry);
@ -890,7 +891,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype); evt = bta_av_proc_meta_cmd (&rc_rsp, &p_data->rc_msg, &ctype);
} else } else
#endif #endif
{
evt = BTA_AV_VENDOR_CMD_EVT; evt = BTA_AV_VENDOR_CMD_EVT;
}
} }
/* else if configured to support vendor specific and it's a response */ /* else if configured to support vendor specific and it's a response */
else if ((p_cb->features & BTA_AV_FEAT_VENDOR) && else if ((p_cb->features & BTA_AV_FEAT_VENDOR) &&
@ -902,7 +905,9 @@ void bta_av_rc_msg(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
evt = BTA_AV_META_MSG_EVT; evt = BTA_AV_META_MSG_EVT;
} else } else
#endif #endif
{
evt = BTA_AV_VENDOR_RSP_EVT; evt = BTA_AV_VENDOR_RSP_EVT;
}
} }
/* else if not configured to support vendor specific and it's a command */ /* else if not configured to support vendor specific and it's a command */

View file

@ -636,13 +636,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
/* set modes for Discoverability and connectability if not ignore */ /* set modes for Discoverability and connectability if not ignore */
if (p_data->set_visibility.disc_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) { if (p_data->set_visibility.disc_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) if ((p_data->set_visibility.disc_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
p_data->set_visibility.disc_mode = p_data->set_visibility.disc_mode =
((p_data->set_visibility.disc_mode & ~BTA_DM_LE_IGNORE) | le_disc_mode); ((p_data->set_visibility.disc_mode & ~BTA_DM_LE_IGNORE) | le_disc_mode);
}
if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) if ((p_data->set_visibility.disc_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
p_data->set_visibility.disc_mode = p_data->set_visibility.disc_mode =
((p_data->set_visibility.disc_mode & ~BTA_DM_IGNORE) | disc_mode); ((p_data->set_visibility.disc_mode & ~BTA_DM_IGNORE) | disc_mode);
}
BTM_SetDiscoverability(p_data->set_visibility.disc_mode, BTM_SetDiscoverability(p_data->set_visibility.disc_mode,
bta_dm_cb.inquiry_scan_window, bta_dm_cb.inquiry_scan_window,
@ -650,13 +652,15 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
} }
if (p_data->set_visibility.conn_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) { if (p_data->set_visibility.conn_mode != (BTA_DM_IGNORE | BTA_DM_LE_IGNORE)) {
if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) if ((p_data->set_visibility.conn_mode & BTA_DM_LE_IGNORE) == BTA_DM_LE_IGNORE) {
p_data->set_visibility.conn_mode = p_data->set_visibility.conn_mode =
((p_data->set_visibility.conn_mode & ~BTA_DM_LE_IGNORE) | le_conn_mode); ((p_data->set_visibility.conn_mode & ~BTA_DM_LE_IGNORE) | le_conn_mode);
}
if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) if ((p_data->set_visibility.conn_mode & BTA_DM_IGNORE) == BTA_DM_IGNORE) {
p_data->set_visibility.conn_mode = p_data->set_visibility.conn_mode =
((p_data->set_visibility.conn_mode & ~BTA_DM_IGNORE) | conn_mode); ((p_data->set_visibility.conn_mode & ~BTA_DM_IGNORE) | conn_mode);
}
BTM_SetConnectability(p_data->set_visibility.conn_mode, BTM_SetConnectability(p_data->set_visibility.conn_mode,
bta_dm_cb.page_scan_window, bta_dm_cb.page_scan_window,
@ -1886,10 +1890,12 @@ void bta_dm_disc_result (tBTA_DM_MSG *p_data)
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
/* if any BR/EDR service discovery has been done, report the event */ /* if any BR/EDR service discovery has been done, report the event */
if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK))) if ((bta_dm_search_cb.services & ((BTA_ALL_SERVICE_MASK | BTA_USER_SERVICE_MASK ) & ~BTA_BLE_SERVICE_MASK))) {
#endif
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result); bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
}
#else
bta_dm_search_cb.p_search_cback(BTA_DM_DISC_RES_EVT, &p_data->disc_result.result);
#endif
tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG)); tBTA_DM_MSG *p_msg = (tBTA_DM_MSG *) osi_malloc(sizeof(tBTA_DM_MSG));
/* send a message to change state */ /* send a message to change state */
@ -2155,9 +2161,10 @@ static void bta_dm_find_services ( BD_ADDR bd_addr)
} }
/* last one? clear the BLE service bit if all discovery has been done */ /* last one? clear the BLE service bit if all discovery has been done */
if (bta_dm_search_cb.uuid_to_search == 0) if (bta_dm_search_cb.uuid_to_search == 0) {
bta_dm_search_cb.services_to_search &= bta_dm_search_cb.services_to_search &=
(tBTA_SERVICE_MASK)(~(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index))); (tBTA_SERVICE_MASK)(~(BTA_SERVICE_ID_TO_SERVICE_MASK(bta_dm_search_cb.service_index)));
}
} else } else
#endif #endif
@ -3640,11 +3647,11 @@ static char *bta_dm_get_remname(void)
char *p_temp; char *p_temp;
/* If the name isn't already stored, try retrieving from BTM */ /* If the name isn't already stored, try retrieving from BTM */
if (*p_name == '\0') if (*p_name == '\0') {
if ((p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)) != NULL) { if ((p_temp = BTM_SecReadDevName(bta_dm_search_cb.peer_bdaddr)) != NULL) {
p_name = p_temp; p_name = p_temp;
} }
}
return p_name; return p_name;
} }
#endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE #endif ///SDP_INCLUDED == TRUE || SMP_INCLUDED == TRUE
@ -5181,9 +5188,10 @@ void bta_dm_ble_setup_storage (tBTA_DM_MSG *p_data)
p_data->ble_set_storage.ref_value); p_data->ble_set_storage.ref_value);
} }
if (BTM_CMD_STARTED != btm_status) if (BTM_CMD_STARTED != btm_status) {
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, p_data->ble_set_storage.ref_value, bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_CFG_STRG_EVT, p_data->ble_set_storage.ref_value,
btm_status); btm_status);
}
} }
/******************************************************************************* /*******************************************************************************
@ -5211,9 +5219,10 @@ void bta_dm_ble_enable_batch_scan (tBTA_DM_MSG *p_data)
p_data->ble_enable_scan.ref_value); p_data->ble_enable_scan.ref_value);
} }
if (BTM_CMD_STARTED != btm_status) if (BTM_CMD_STARTED != btm_status) {
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_ENABLE_EVT, p_data->ble_enable_scan.ref_value, bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_ENABLE_EVT, p_data->ble_enable_scan.ref_value,
btm_status); btm_status);
}
} }
/******************************************************************************* /*******************************************************************************
@ -5237,9 +5246,10 @@ void bta_dm_ble_disable_batch_scan (tBTA_DM_MSG *p_data)
btm_status = BTM_BleDisableBatchScan(p_data->ble_disable_scan.ref_value); btm_status = BTM_BleDisableBatchScan(p_data->ble_disable_scan.ref_value);
} }
if (BTM_CMD_STARTED != btm_status) if (BTM_CMD_STARTED != btm_status) {
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_DISABLE_EVT, p_data->ble_enable_scan.ref_value, bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_DISABLE_EVT, p_data->ble_enable_scan.ref_value,
btm_status); btm_status);
}
} }
/******************************************************************************* /*******************************************************************************
@ -5263,9 +5273,10 @@ void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data)
p_data->ble_read_reports.ref_value); p_data->ble_read_reports.ref_value);
} }
if (BTM_CMD_STARTED != btm_status) if (BTM_CMD_STARTED != btm_status) {
bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, p_data->ble_enable_scan.ref_value, bta_ble_scan_setup_cb(BTM_BLE_BATCH_SCAN_READ_REPTS_EVT, p_data->ble_enable_scan.ref_value,
btm_status); btm_status);
}
} }
/******************************************************************************* /*******************************************************************************
@ -5395,10 +5406,11 @@ void bta_dm_cfg_filter_cond (tBTA_DM_MSG *p_data)
} }
} }
if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback) if (p_data->ble_cfg_filter_cond.p_filt_cfg_cback) {
p_data->ble_cfg_filter_cond.p_filt_cfg_cback(BTA_DM_BLE_PF_CONFIG_EVT, p_data->ble_cfg_filter_cond.p_filt_cfg_cback(BTA_DM_BLE_PF_CONFIG_EVT,
p_data->ble_cfg_filter_cond.cond_type, 0, status, p_data->ble_cfg_filter_cond.cond_type, 0, status,
p_data->ble_cfg_filter_cond.ref_value); p_data->ble_cfg_filter_cond.ref_value);
}
return; return;
} }
@ -5429,9 +5441,10 @@ void bta_dm_enable_scan_filter(tBTA_DM_MSG *p_data)
return; return;
} }
if (p_data->ble_enable_scan_filt.p_filt_status_cback) if (p_data->ble_enable_scan_filt.p_filt_status_cback) {
p_data->ble_enable_scan_filt.p_filt_status_cback (BTA_DM_BLE_PF_ENABLE_EVT, p_data->ble_enable_scan_filt.p_filt_status_cback (BTA_DM_BLE_PF_ENABLE_EVT,
p_data->ble_enable_scan_filt.ref_value, status); p_data->ble_enable_scan_filt.ref_value, status);
}
} }
@ -5465,9 +5478,10 @@ void bta_dm_scan_filter_param_setup (tBTA_DM_MSG *p_data)
} }
} }
if (p_data->ble_scan_filt_param_setup.p_filt_param_cback) if (p_data->ble_scan_filt_param_setup.p_filt_param_cback) {
p_data->ble_scan_filt_param_setup.p_filt_param_cback (BTA_DM_BLE_PF_ENABLE_EVT, 0, p_data->ble_scan_filt_param_setup.p_filt_param_cback (BTA_DM_BLE_PF_ENABLE_EVT, 0,
p_data->ble_scan_filt_param_setup.ref_value, status); p_data->ble_scan_filt_param_setup.ref_value, status);
}
return; return;
} }

View file

@ -1038,9 +1038,10 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive)
bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive); bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive);
/* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */ /* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */
if (!bScoActive) if (!bScoActive) {
bta_dm_pm_set_mode(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, BTA_DM_PM_NO_ACTION, bta_dm_pm_set_mode(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, BTA_DM_PM_NO_ACTION,
BTA_DM_PM_RESTART); BTA_DM_PM_RESTART);
}
} }
} }

View file

@ -674,7 +674,7 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK); bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
//register service change //register service change
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda); bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
} else } else
#endif #endif
{ /* cache is building */ { /* cache is building */
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC; p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
@ -1071,8 +1071,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
*******************************************************************************/ *******************************************************************************/
void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{ {
if (!bta_gattc_enqueue(p_clcb, p_data)) if (!bta_gattc_enqueue(p_clcb, p_data)) {
return; return;
}
tGATT_READ_PARAM read_param; tGATT_READ_PARAM read_param;
memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM)); memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
@ -1140,8 +1141,9 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
*******************************************************************************/ *******************************************************************************/
void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data) void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{ {
if (!bta_gattc_enqueue(p_clcb, p_data)) if (!bta_gattc_enqueue(p_clcb, p_data)) {
return; return;
}
tBTA_GATT_STATUS status = BTA_GATT_OK; tBTA_GATT_STATUS status = BTA_GATT_OK;
tGATT_VALUE attr; tGATT_VALUE attr;
@ -1742,7 +1744,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
tBTA_GATTC gattc_cb = {0}; tBTA_GATTC gattc_cb = {0};
gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if; gattc_cb.set_assoc.client_if = p_msg->api_assoc.client_if;
BOOLEAN state = FALSE; BOOLEAN state = FALSE;
tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if, tBTA_GATTC_CLCB *p_assoc_clcb = bta_gattc_find_clcb_by_cif(p_msg->api_assoc.client_if,
p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE); p_msg->api_assoc.assoc_addr, BTA_TRANSPORT_LE);
tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if); tBTA_GATTC_RCB *p_clrcb = bta_gattc_cl_get_regcb(p_msg->api_assoc.client_if);
if (p_assoc_clcb != NULL) { if (p_assoc_clcb != NULL) {
@ -1783,7 +1785,7 @@ void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_m
} }
return; return;
} }
void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
{ {

View file

@ -93,7 +93,7 @@ static char *bta_gattc_attr_type[] = {
}; };
/* utility functions */ /* utility functions */
bool display_cache_attribute(void *data, void *context) bool display_cache_attribute(void *data, void *context)
{ {
//tBTA_GATTC_CACHE_ATTR *p_attr = data; //tBTA_GATTC_CACHE_ATTR *p_attr = data;
//APPL_TRACE_ERROR("\t Attr handle[%d] uuid[0x%04x] type[%s] prop[0x%1x]", //APPL_TRACE_ERROR("\t Attr handle[%d] uuid[0x%04x] type[%s] prop[0x%1x]",
@ -102,7 +102,7 @@ bool display_cache_attribute(void *data, void *context)
return true; return true;
} }
bool display_cache_service(void *data, void *context) bool display_cache_service(void *data, void *context)
{ {
tBTA_GATTC_SERVICE *p_cur_srvc = data; tBTA_GATTC_SERVICE *p_cur_srvc = data;
APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]", APPL_TRACE_API("Service: handle[%d ~ %d] %s[0x%04x] inst[%d]",
@ -213,9 +213,9 @@ static void bta_gattc_free(void *ptr)
osi_free(ptr); osi_free(ptr);
} }
void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc) void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE *p_new_srvc)
{ {
// services/p_new_srvc is NULL // services/p_new_srvc is NULL
if (!services || !p_new_srvc) { if (!services || !p_new_srvc) {
APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__); APPL_TRACE_ERROR("%s services/p_new_srvc is NULL", __func__);
return; return;
@ -243,7 +243,7 @@ void bta_gattc_insert_sec_service_to_cache(list_t *services, tBTA_GATTC_SERVICE
return; return;
} }
} }
} }
} }
} }
@ -314,8 +314,9 @@ static tBTA_GATT_STATUS bta_gattc_add_char_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
/* TODO(jpawlowski): We should use attribute handle, not value handle to refer to characteristic. /* TODO(jpawlowski): We should use attribute handle, not value handle to refer to characteristic.
This is just a temporary workaround. This is just a temporary workaround.
*/ */
if (service->e_handle < value_handle) if (service->e_handle < value_handle) {
service->e_handle = value_handle; service->e_handle = value_handle;
}
tBTA_GATTC_CHARACTERISTIC *characteristic = osi_malloc(sizeof(tBTA_GATTC_CHARACTERISTIC)); tBTA_GATTC_CHARACTERISTIC *characteristic = osi_malloc(sizeof(tBTA_GATTC_CHARACTERISTIC));
if (!characteristic) { if (!characteristic) {
@ -554,10 +555,10 @@ void bta_gattc_update_include_service(const list_t *services) {
if(include_service && !include_service->included_service) { if(include_service && !include_service->included_service) {
//update //update
include_service->included_service = bta_gattc_find_matching_service(services, include_service->incl_srvc_s_handle); include_service->included_service = bta_gattc_find_matching_service(services, include_service->incl_srvc_s_handle);
if(!include_service->included_service) { if(!include_service->included_service) {
//not match, free it //not match, free it
list_remove(service->included_svc, include_service); list_remove(service->included_svc, include_service);
osi_free(include_service); osi_free(include_service);
} }
} }
} }
@ -980,12 +981,13 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
p_data->value.incl_service.e_handle, p_data->value.incl_service.e_handle,
p_data->value.incl_service.service_type); p_data->value.incl_service.service_type);
if (!pri_srvc) if (!pri_srvc) {
bta_gattc_add_srvc_to_list(p_srvc_cb, bta_gattc_add_srvc_to_list(p_srvc_cb,
p_data->value.incl_service.s_handle, p_data->value.incl_service.s_handle,
p_data->value.incl_service.e_handle, p_data->value.incl_service.e_handle,
p_data->value.incl_service.service_type, p_data->value.incl_service.service_type,
FALSE); FALSE);
}
/* add into database */ /* add into database */
bta_gattc_add_attr_to_cache(p_srvc_cb, bta_gattc_add_attr_to_cache(p_srvc_cb,
p_data->handle, p_data->handle,
@ -1007,8 +1009,8 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
case GATT_DISC_CHAR_DSCPT: case GATT_DISC_CHAR_DSCPT:
bta_gattc_add_attr_to_cache(p_srvc_cb, bta_gattc_add_attr_to_cache(p_srvc_cb,
p_data->handle, p_data->handle,
&p_data->type, &p_data->type,
0, 0,
0 /* incl_srvc_s_handle */, 0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */, 0 /* incl_srvc_e_handle */,
@ -1023,8 +1025,9 @@ void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
if ( p_clcb && (status != GATT_SUCCESS || p_clcb->status != GATT_SUCCESS) ) { if ( p_clcb && (status != GATT_SUCCESS || p_clcb->status != GATT_SUCCESS) ) {
if (status == GATT_SUCCESS) if (status == GATT_SUCCESS) {
p_clcb->status = status; p_clcb->status = status;
}
bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL); bta_gattc_sm_execute(p_clcb, BTA_GATTC_DISCOVER_CMPL_EVT, NULL);
return; return;
} }
@ -1071,15 +1074,17 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
{ {
tBTA_GATTC cb_data; tBTA_GATTC cb_data;
if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache)) if (!p_clcb->p_srcb->p_srvc_cache || list_is_empty(p_clcb->p_srcb->p_srvc_cache)) {
return; return;
}
for (list_node_t *sn = list_begin(p_clcb->p_srcb->p_srvc_cache); for (list_node_t *sn = list_begin(p_clcb->p_srcb->p_srvc_cache);
sn != list_end(p_clcb->p_srcb->p_srvc_cache); sn = list_next(sn)) { sn != list_end(p_clcb->p_srcb->p_srvc_cache); sn = list_next(sn)) {
tBTA_GATTC_SERVICE *p_cache = list_node(sn); tBTA_GATTC_SERVICE *p_cache = list_node(sn);
if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE)) if (!bta_gattc_uuid_compare(p_uuid, &p_cache->uuid, FALSE)) {
continue; continue;
}
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE) #if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
APPL_TRACE_DEBUG("found service [0x%04x], inst[%d] handle [%d]", APPL_TRACE_DEBUG("found service [0x%04x], inst[%d] handle [%d]",
@ -1087,8 +1092,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
p_cache->handle, p_cache->handle,
p_cache->s_handle); p_cache->s_handle);
#endif #endif
if (!p_clcb->p_rcb->p_cback) if (!p_clcb->p_rcb->p_cback) {
continue; continue;
}
memset(&cb_data, 0, sizeof(tBTA_GATTC)); memset(&cb_data, 0, sizeof(tBTA_GATTC));
@ -1103,8 +1109,9 @@ void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid)
} }
list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) { list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) if (!p_srcb || !p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
return NULL; return NULL;
}
return p_srcb->p_srvc_cache; return p_srcb->p_srvc_cache;
} }
@ -1112,8 +1119,9 @@ list_t* bta_gattc_get_services_srcb(tBTA_GATTC_SERV *p_srcb) {
const list_t* bta_gattc_get_services(UINT16 conn_id) { const list_t* bta_gattc_get_services(UINT16 conn_id) {
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
if (p_clcb == NULL ) if (p_clcb == NULL ) {
return NULL; return NULL;
}
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
@ -1121,63 +1129,68 @@ const list_t* bta_gattc_get_services(UINT16 conn_id) {
} }
tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle) { tBTA_GATTC_SERVICE* bta_gattc_find_matching_service(const list_t *services, UINT16 handle) {
if (!services || list_is_empty(services)) if (!services || list_is_empty(services)) {
return NULL; return NULL;
}
for (list_node_t *sn = list_begin(services); for (list_node_t *sn = list_begin(services);
sn != list_end(services); sn = list_next(sn)) { sn != list_end(services); sn = list_next(sn)) {
tBTA_GATTC_SERVICE *service = list_node(sn); tBTA_GATTC_SERVICE *service = list_node(sn);
if (handle >= service->s_handle && handle <= service->e_handle) if (handle >= service->s_handle && handle <= service->e_handle) {
return service; return service;
}
} }
return NULL; return NULL;
} }
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle) const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
{ {
const list_t *services = bta_gattc_get_services_srcb(p_srcb); const list_t *services = bta_gattc_get_services_srcb(p_srcb);
return bta_gattc_find_matching_service(services, handle); return bta_gattc_find_matching_service(services, handle);
} }
const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle) const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle)
{ {
const list_t *services = bta_gattc_get_services(conn_id); const list_t *services = bta_gattc_get_services(conn_id);
return bta_gattc_find_matching_service(services, handle); return bta_gattc_find_matching_service(services, handle);
} }
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle) tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
{ {
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle); const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
if (!service) if (!service) {
return NULL; return NULL;
}
for (list_node_t *cn = list_begin(service->characteristics); for (list_node_t *cn = list_begin(service->characteristics);
cn != list_end(service->characteristics); cn = list_next(cn)) { cn != list_end(service->characteristics); cn = list_next(cn)) {
tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn); tBTA_GATTC_CHARACTERISTIC *p_char = list_node(cn);
if (handle == p_char->handle) if (handle == p_char->handle) {
return p_char; return p_char;
}
} }
return NULL; return NULL;
} }
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle) tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle)
{ {
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
if (p_clcb == NULL ) if (p_clcb == NULL ) {
return NULL; return NULL;
}
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
return bta_gattc_get_characteristic_srcb(p_srcb, handle); return bta_gattc_get_characteristic_srcb(p_srcb, handle);
} }
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle) tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle)
{ {
const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle); const tBTA_GATTC_SERVICE* service = bta_gattc_get_service_for_handle_srcb(p_srcb, handle);
@ -1191,20 +1204,22 @@ tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor_srcb(tBTA_GATTC_SERV *p_srcb, U
for (list_node_t *dn = list_begin(p_char->descriptors); for (list_node_t *dn = list_begin(p_char->descriptors);
dn != list_end(p_char->descriptors); dn = list_next(dn)) { dn != list_end(p_char->descriptors); dn = list_next(dn)) {
tBTA_GATTC_DESCRIPTOR *p_desc = list_node(dn); tBTA_GATTC_DESCRIPTOR *p_desc = list_node(dn);
if (handle == p_desc->handle) if (handle == p_desc->handle) {
return p_desc; return p_desc;
}
} }
} }
return NULL; return NULL;
} }
tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle) tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle)
{ {
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id); tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
if (p_clcb == NULL ) if (p_clcb == NULL ) {
return NULL; return NULL;
}
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
return bta_gattc_get_descriptor_srcb(p_srcb, handle); return bta_gattc_get_descriptor_srcb(p_srcb, handle);
@ -1443,7 +1458,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
} }
} }
} }
} }
} }
@ -1476,7 +1491,7 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
} }
if (type == BTGATT_DB_PRIMARY_SERVICE || type == BTGATT_DB_SECONDARY_SERVICE) { if (type == BTGATT_DB_PRIMARY_SERVICE || type == BTGATT_DB_SECONDARY_SERVICE) {
if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) || if ((type == BTGATT_DB_PRIMARY_SERVICE && p_cur_srvc->is_primary) ||
(type == BTGATT_DB_SECONDARY_SERVICE && !p_cur_srvc->is_primary)) { (type == BTGATT_DB_SECONDARY_SERVICE && !p_cur_srvc->is_primary)) {
// if the current service is the last service in the db, need to ensure the current service start handle is not less than the start_handle. // if the current service is the last service in the db, need to ensure the current service start handle is not less than the start_handle.
if (!svc_length) { if (!svc_length) {
@ -1572,10 +1587,11 @@ static size_t bta_gattc_get_db_size_with_type(list_t *services,
** Returns number of elements inside db from start_handle to end_handle ** Returns number of elements inside db from start_handle to end_handle
*******************************************************************************/ *******************************************************************************/
static size_t bta_gattc_get_db_size(list_t *services, static size_t bta_gattc_get_db_size(list_t *services,
UINT16 start_handle, UINT16 end_handle) UINT16 start_handle, UINT16 end_handle)
{ {
if (!services || list_is_empty(services)) if (!services || list_is_empty(services)) {
return 0; return 0;
}
size_t db_size = 0; size_t db_size = 0;
UINT16 svc_length = list_length(services) - 1; UINT16 svc_length = list_length(services) - 1;
@ -1598,9 +1614,10 @@ static size_t bta_gattc_get_db_size(list_t *services,
} else { } else {
db_size++; db_size++;
} }
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
continue; continue;
}
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics); for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) { cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
@ -1657,7 +1674,7 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
*count = 0; *count = 0;
return; return;
} }
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) { if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
*count = 0; *count = 0;
@ -1676,7 +1693,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
*count = 0; *count = 0;
return; return;
} }
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb; tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) { if (!p_srcb->p_srvc_cache || list_is_empty(p_srcb->p_srvc_cache)) {
*count = 0; *count = 0;
@ -1694,7 +1711,7 @@ void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute
} }
} }
*count = bta_gattc_get_db_size_with_type(p_srcb->p_srvc_cache, type, NULL, start_handle, end_handle); *count = bta_gattc_get_db_size_with_type(p_srcb->p_srvc_cache, type, NULL, start_handle, end_handle);
} }
/******************************************************************************* /*******************************************************************************
@ -1786,8 +1803,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
p_char->properties); p_char->properties);
curr_db_attr++; curr_db_attr++;
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
continue; continue;
}
for (list_node_t *dn = list_begin(p_char->descriptors); for (list_node_t *dn = list_begin(p_char->descriptors);
dn != list_end(p_char->descriptors); dn = list_next(dn)) { dn != list_end(p_char->descriptors); dn = list_next(dn)) {
@ -1815,8 +1833,9 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV *p_srvc_cb,
} }
} }
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
continue; continue;
}
for (list_node_t *isn = list_begin(p_cur_srvc->included_svc); for (list_node_t *isn = list_begin(p_cur_srvc->included_svc);
isn != list_end(p_cur_srvc->included_svc); isn = list_next(isn)) { isn != list_end(p_cur_srvc->included_svc); isn = list_next(isn)) {
@ -1983,8 +2002,9 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
*******************************************************************************/ *******************************************************************************/
void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id) void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
{ {
if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache)) if (!p_srvc_cb->p_srvc_cache || list_is_empty(p_srvc_cb->p_srvc_cache)) {
return; return;
}
int i = 0; int i = 0;
size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF); size_t db_size = bta_gattc_get_db_size(p_srvc_cb->p_srvc_cache, 0x0000, 0xFFFF);
@ -2017,8 +2037,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
sn != list_end(p_srvc_cb->p_srvc_cache); sn = list_next(sn)) { sn != list_end(p_srvc_cb->p_srvc_cache); sn = list_next(sn)) {
tBTA_GATTC_SERVICE *p_cur_srvc = list_node(sn); tBTA_GATTC_SERVICE *p_cur_srvc = list_node(sn);
if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) if (!p_cur_srvc->characteristics || list_is_empty(p_cur_srvc->characteristics)) {
continue; continue;
}
for (list_node_t *cn = list_begin(p_cur_srvc->characteristics); for (list_node_t *cn = list_begin(p_cur_srvc->characteristics);
cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) { cn != list_end(p_cur_srvc->characteristics); cn = list_next(cn)) {
@ -2034,8 +2055,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
0 /* incl_srvc_e_handle */, 0 /* incl_srvc_e_handle */,
FALSE); FALSE);
if (!p_char->descriptors || list_is_empty(p_char->descriptors)) if (!p_char->descriptors || list_is_empty(p_char->descriptors)) {
continue; continue;
}
for (list_node_t *dn = list_begin(p_char->descriptors); for (list_node_t *dn = list_begin(p_char->descriptors);
dn != list_end(p_char->descriptors); dn = list_next(dn)) { dn != list_end(p_char->descriptors); dn = list_next(dn)) {
@ -2053,8 +2075,9 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
} }
} }
if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) if (!p_cur_srvc->included_svc || list_is_empty(p_cur_srvc->included_svc)) {
continue; continue;
}
for (list_node_t *an = list_begin(p_cur_srvc->included_svc); for (list_node_t *an = list_begin(p_cur_srvc->included_svc);
an != list_end(p_cur_srvc->included_svc); an = list_next(an)) { an != list_end(p_cur_srvc->included_svc); an = list_next(an)) {

View file

@ -416,8 +416,9 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
if (p_tcb != NULL) if (p_tcb != NULL)
{ {
if (p_tcb->p_srvc_cache != NULL) if (p_tcb->p_srvc_cache != NULL) {
list_free(p_tcb->p_srvc_cache); list_free(p_tcb->p_srvc_cache);
}
osi_free(p_tcb->p_srvc_list); osi_free(p_tcb->p_srvc_list);
p_tcb->p_srvc_list = NULL; p_tcb->p_srvc_list = NULL;
//osi_free_and_reset((void **)&p_tcb->p_srvc_list); //osi_free_and_reset((void **)&p_tcb->p_srvc_list);
@ -583,8 +584,9 @@ void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id,
* clear boundaries are always around service. * clear boundaries are always around service.
*/ */
handle = p_clrcb->notif_reg[i].handle; handle = p_clrcb->notif_reg[i].handle;
if (handle >= start_handle && handle <= end_handle) if (handle >= start_handle && handle <= end_handle) {
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG)); memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
}
} }
} }
} }
@ -936,8 +938,9 @@ void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src)
if (p_src->len == LEN_UUID_16 || p_src->len == LEN_UUID_32) if (p_src->len == LEN_UUID_16 || p_src->len == LEN_UUID_32)
{ {
for(i=0; i != 16; ++i) for(i=0; i != 16; ++i) {
p_dest->uu[i] = base_uuid[i]; p_dest->uu[i] = base_uuid[i];
}
} }
switch (p_src->len) switch (p_src->len)

View file

@ -403,7 +403,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
UINT16 attr_id = 0; UINT16 attr_id = 0;
tBTA_GATTS cb_data; tBTA_GATTS cb_data;
tGATT_ATTR_VAL *p_attr_val = NULL; tGATT_ATTR_VAL *p_attr_val = NULL;
tGATTS_ATTR_CONTROL *p_control = NULL; tGATTS_ATTR_CONTROL *p_control = NULL;
if(p_msg->api_add_char.attr_val.attr_max_len != 0){ if(p_msg->api_add_char.attr_val.attr_max_len != 0){
@ -665,17 +665,18 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
&gatt_if, remote_bda, &transport)) { &gatt_if, remote_bda, &transport)) {
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if); p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
if (p_msg->api_indicate.need_confirm) if (p_msg->api_indicate.need_confirm) {
status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific, status = GATTS_HandleValueIndication (p_msg->api_indicate.hdr.layer_specific,
p_msg->api_indicate.attr_id, p_msg->api_indicate.attr_id,
p_msg->api_indicate.len, p_msg->api_indicate.len,
p_msg->api_indicate.value); p_msg->api_indicate.value);
else } else {
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific, status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
p_msg->api_indicate.attr_id, p_msg->api_indicate.attr_id,
p_msg->api_indicate.len, p_msg->api_indicate.len,
p_msg->api_indicate.value); p_msg->api_indicate.value);
}
/* if over BR_EDR, inform PM for mode change */ /* if over BR_EDR, inform PM for mode change */
if (transport == BTA_TRANSPORT_BR_EDR) { if (transport == BTA_TRANSPORT_BR_EDR) {
@ -851,13 +852,13 @@ void bta_gatts_send_service_change_indication (tBTA_GATTS_DATA *p_msg)
memcpy(bd_addr, p_msg->api_send_service_change.remote_bda, BD_ADDR_LEN); memcpy(bd_addr, p_msg->api_send_service_change.remote_bda, BD_ADDR_LEN);
status = GATT_SendServiceChangeIndication(bd_addr); status = GATT_SendServiceChangeIndication(bd_addr);
} else { } else {
status = GATT_SendServiceChangeIndication(NULL); status = GATT_SendServiceChangeIndication(NULL);
} }
if (p_rcb && p_rcb->p_cback) { if (p_rcb && p_rcb->p_cback) {
service_change.status = status; service_change.status = status;
service_change.server_if = p_msg->api_send_service_change.server_if; service_change.server_if = p_msg->api_send_service_change.server_if;
(*p_rcb->p_cback)(BTA_GATTS_SEND_SERVICE_CHANGE_EVT, (tBTA_GATTS *)&service_change); (*p_rcb->p_cback)(BTA_GATTS_SEND_SERVICE_CHANGE_EVT, (tBTA_GATTS *)&service_change);
} }
} }
/******************************************************************************* /*******************************************************************************
@ -933,7 +934,7 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data; cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data;
if(req_type == BTA_GATTS_CONF_EVT) { if(req_type == BTA_GATTS_CONF_EVT) {
cb_data.req_data.handle = p_data->handle; cb_data.req_data.handle = p_data->handle;
} }
(*p_rcb->p_cback)(req_type, &cb_data); (*p_rcb->p_cback)(req_type, &cb_data);
} else { } else {

View file

@ -101,8 +101,10 @@ void bta_hh_api_enable(tBTA_HH_DATA *p_data)
bta_hh_le_enable(); bta_hh_le_enable();
} else } else
#endif #endif
{
/* signal BTA call back event */ /* signal BTA call back event */
(* bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, (tBTA_HH *)&status); (* bta_hh_cb.p_cback)(BTA_HH_ENABLE_EVT, (tBTA_HH *)&status);
}
} }
/******************************************************************************* /*******************************************************************************
** **
@ -901,7 +903,9 @@ void bta_hh_get_dscp_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
bta_hh_le_get_dscp_act(p_cb); bta_hh_le_get_dscp_act(p_cb);
} else } else
#endif #endif
{
(*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info); (*bta_hh_cb.p_cback)(BTA_HH_GET_DSCP_EVT, (tBTA_HH *)&p_cb->dscp_info);
}
} }
/******************************************************************************* /*******************************************************************************
@ -934,11 +938,10 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
dev_info.status = BTA_HH_OK; dev_info.status = BTA_HH_OK;
} else } else
#endif #endif
{
if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask, &dev_handle)\ if (HID_HostAddDev(p_dev_info->bda, p_dev_info->attr_mask, &dev_handle)\
== HID_SUCCESS) { == HID_SUCCESS) {
dev_info.handle = dev_handle; dev_info.handle = dev_handle;
dev_info.status = BTA_HH_OK;
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE) #if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
/* update DI information */ /* update DI information */
@ -966,6 +969,7 @@ void bta_hh_maint_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data)
/* update cb_index[] map */ /* update cb_index[] map */
bta_hh_cb.cb_index[dev_handle] = p_cb->index; bta_hh_cb.cb_index[dev_handle] = p_cb->index;
} }
}
} else { /* device already been added */ } else { /* device already been added */
dev_info.handle = p_cb->hid_handle; dev_info.handle = p_cb->hid_handle;
dev_info.status = BTA_HH_OK; dev_info.status = BTA_HH_OK;

View file

@ -2183,9 +2183,10 @@ void bta_hh_le_write_char_descr_cmpl(tBTA_HH_DEV_CB *p_dev_cb, tBTA_HH_DATA *p_b
case GATT_UUID_HID_BT_KB_INPUT: case GATT_UUID_HID_BT_KB_INPUT:
case GATT_UUID_HID_BT_MOUSE_INPUT: case GATT_UUID_HID_BT_MOUSE_INPUT:
case GATT_UUID_HID_REPORT: case GATT_UUID_HID_REPORT:
if (p_data->status == BTA_GATT_OK) if (p_data->status == BTA_GATT_OK) {
p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value = p_dev_cb->hid_srvc[hid_inst_id].report[p_dev_cb->clt_cfg_idx].client_cfg_value =
BTA_GATT_CLT_CONFIG_NOTIFICATION; BTA_GATT_CLT_CONFIG_NOTIFICATION;
}
p_dev_cb->clt_cfg_idx ++; p_dev_cb->clt_cfg_idx ++;
bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id); bta_hh_le_write_rpt_clt_cfg(p_dev_cb, hid_inst_id);

View file

@ -75,11 +75,12 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
return xx; return xx;
} }
#if BTA_HH_DEBUG #if BTA_HH_DEBUG
else else {
APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]", APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]",
bta_hh_cb.kdev[xx].in_use, xx, bta_hh_cb.kdev[xx].in_use, xx,
bta_hh_cb.kdev[xx].hid_handle, bta_hh_cb.kdev[xx].hid_handle,
bta_hh_cb.kdev[xx].state); bta_hh_cb.kdev[xx].state);
}
#endif #endif
} }
@ -123,7 +124,9 @@ void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb)
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID; bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID;
} else } else
#endif #endif
{
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID; bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
}
} }
/* reset device control block */ /* reset device control block */
@ -486,11 +489,12 @@ UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle)
#endif #endif
} else } else
#endif #endif
{
/* regular HID device checking */ /* regular HID device checking */
if (dev_handle < BTA_HH_MAX_KNOWN ) { if (dev_handle < BTA_HH_MAX_KNOWN ) {
index = bta_hh_cb.cb_index[dev_handle]; index = bta_hh_cb.cb_index[dev_handle];
} }
}
return index; return index;
} }

View file

@ -747,9 +747,10 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
bta_jv_cb.scn[channel - 1] = TRUE; bta_jv_cb.scn[channel - 1] = TRUE;
scn = (UINT8) channel; scn = (UINT8) channel;
} }
if (bta_jv_cb.p_dm_cback) if (bta_jv_cb.p_dm_cback) {
bta_jv_cb.p_dm_cback(BTA_JV_GET_SCN_EVT, (tBTA_JV *)&scn, bta_jv_cb.p_dm_cback(BTA_JV_GET_SCN_EVT, (tBTA_JV *)&scn,
p_data->alloc_channel.user_data); p_data->alloc_channel.user_data);
}
return; return;
} }
case BTA_JV_CONN_TYPE_L2CAP: case BTA_JV_CONN_TYPE_L2CAP:

View file

@ -195,8 +195,9 @@ bt_status_t btc_hf_client_init(void)
*******************************************************************************/ *******************************************************************************/
static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid ) static bt_status_t connect_int( bt_bdaddr_t *bd_addr, uint16_t uuid )
{ {
if (is_connected(bd_addr)) if (is_connected(bd_addr)) {
return BT_STATUS_BUSY; return BT_STATUS_BUSY;
}
btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING; btc_hf_client_cb.state = ESP_HF_CLIENT_CONNECTION_STATE_CONNECTING;
bdcpy(btc_hf_client_cb.connected_bda.address, bd_addr->address); bdcpy(btc_hf_client_cb.connected_bda.address, bd_addr->address);
@ -803,11 +804,13 @@ void btc_hf_client_cb_handler(btc_msg_t *msg)
btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, &param); btc_hf_client_cb_to_app(ESP_HF_CLIENT_CONNECTION_STATE_EVT, &param);
} while (0); } while (0);
if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED) if (btc_hf_client_cb.state == ESP_HF_CLIENT_CONNECTION_STATE_DISCONNECTED) {
bdsetany(btc_hf_client_cb.connected_bda.address); bdsetany(btc_hf_client_cb.connected_bda.address);
}
if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) if (p_data->open.status != BTA_HF_CLIENT_SUCCESS) {
btc_queue_advance(); btc_queue_advance();
}
break; break;

View file

@ -145,9 +145,10 @@ void sbc_enc_bit_alloc_mono(SBC_ENC_PARAMS *pstrCodecParams)
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) { for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
if (*(ps16GenBufPtr) < s32BitSlice + 2) { if (*(ps16GenBufPtr) < s32BitSlice + 2) {
*(ps16GenArrPtr) = 0; *(ps16GenArrPtr) = 0;
} else } else {
*(ps16GenArrPtr) = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ? *(ps16GenArrPtr) = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16; (SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
}
ps16GenBufPtr++; ps16GenBufPtr++;
ps16GenArrPtr++; ps16GenArrPtr++;

View file

@ -132,9 +132,10 @@ void sbc_enc_bit_alloc_ste(SBC_ENC_PARAMS *pstrCodecParams)
for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) { for (s32Sb = 0; s32Sb < s32NumOfSubBands; s32Sb++) {
if (*ps16GenBufPtr < s32BitSlice + 2) { if (*ps16GenBufPtr < s32BitSlice + 2) {
*ps16GenArrPtr = 0; *ps16GenArrPtr = 0;
} else } else {
*ps16GenArrPtr = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ? *ps16GenArrPtr = ((*(ps16GenBufPtr) - s32BitSlice) < 16) ?
(SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16; (SINT16)(*(ps16GenBufPtr) - s32BitSlice) : 16;
}
ps16GenBufPtr++; ps16GenBufPtr++;
ps16GenArrPtr++; ps16GenArrPtr++;
} }

View file

@ -61,8 +61,9 @@ bool list_contains(const list_t *list, const void *data)
assert(data != NULL); assert(data != NULL);
for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) { for (const list_node_t *node = list_begin(list); node != list_end(list); node = list_next(node)) {
if (list_node(node) == data) if (list_node(node) == data) {
return true; return true;
}
} }
return false; return false;
@ -201,8 +202,9 @@ list_node_t *list_foreach(const list_t *list, list_iter_cb callback, void *conte
for (list_node_t *node = list->head; node; ) { for (list_node_t *node = list->head; node; ) {
list_node_t *next = node->next; list_node_t *next = node->next;
if (!callback(node->data, context)) if (!callback(node->data, context)) {
return node; return node;
}
node = next; node = next;
} }
return NULL; return NULL;

View file

@ -605,8 +605,9 @@ void avct_lcb_free_msg_ind(tAVCT_LCB *p_lcb, tAVCT_LCB_EVT *p_data)
{ {
UNUSED(p_lcb); UNUSED(p_lcb);
if (p_data == NULL) if (p_data == NULL) {
return; return;
}
osi_free(p_data->p_buf); osi_free(p_data->p_buf);
p_data->p_buf = NULL; p_data->p_buf = NULL;

View file

@ -629,15 +629,19 @@ void avdt_scb_hdl_pkt(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
avdt_scb_hdl_pkt_frag(p_scb, p_data); avdt_scb_hdl_pkt_frag(p_scb, p_data);
} else } else
#endif #endif
{
#if AVDT_REPORTING == TRUE #if AVDT_REPORTING == TRUE
if (p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) { if (p_data->p_pkt->layer_specific == AVDT_CHAN_REPORT) {
p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset; p = (UINT8 *)(p_data->p_pkt + 1) + p_data->p_pkt->offset;
avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len); avdt_scb_hdl_report(p_scb, p, p_data->p_pkt->len);
osi_free(p_data->p_pkt); osi_free(p_data->p_pkt);
p_data->p_pkt = NULL; p_data->p_pkt = NULL;
} else } else
#endif #endif
{
avdt_scb_hdl_pkt_no_frag(p_scb, p_data); avdt_scb_hdl_pkt_no_frag(p_scb, p_data);
}
}
} }
/******************************************************************************* /*******************************************************************************
@ -1305,7 +1309,9 @@ void avdt_scb_hdl_write_req(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
if (fixed_queue_is_empty(p_scb->frag_q)) if (fixed_queue_is_empty(p_scb->frag_q))
#endif #endif
{
avdt_scb_hdl_write_req_no_frag(p_scb, p_data); avdt_scb_hdl_write_req_no_frag(p_scb, p_data);
}
#if AVDT_MULTIPLEXING == TRUE #if AVDT_MULTIPLEXING == TRUE
else { else {
avdt_scb_hdl_write_req_frag(p_scb, p_data); avdt_scb_hdl_write_req_frag(p_scb, p_data);

View file

@ -261,9 +261,10 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, BD_NAME bdn,
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
p->transport = transport; p->transport = transport;
#if BLE_PRIVACY_SPT == TRUE #if BLE_PRIVACY_SPT == TRUE
if (transport == BT_TRANSPORT_LE) if (transport == BT_TRANSPORT_LE) {
btm_ble_refresh_local_resolvable_private_addr(bda, btm_ble_refresh_local_resolvable_private_addr(bda,
btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr); btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
}
#else #else
p->conn_addr_type = BLE_ADDR_PUBLIC; p->conn_addr_type = BLE_ADDR_PUBLIC;
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN); memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
@ -2495,15 +2496,17 @@ void btm_acl_chk_peer_pkt_type_support (tACL_CONN *p, UINT16 *p_pkt_type)
} }
/* 2 and 3 MPS support? */ /* 2 and 3 MPS support? */
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) if (!HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
/* Not supported. Add 'not_supported' mask for all 2MPS packet types */ /* Not supported. Add 'not_supported' mask for all 2MPS packet types */
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
BTM_ACL_PKT_TYPES_MASK_NO_2_DH5); BTM_ACL_PKT_TYPES_MASK_NO_2_DH5);
}
if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) if (!HCI_EDR_ACL_3MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])) {
/* Not supported. Add 'not_supported' mask for all 3MPS packet types */ /* Not supported. Add 'not_supported' mask for all 3MPS packet types */
*p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 + *p_pkt_type |= (BTM_ACL_PKT_TYPES_MASK_NO_3_DH1 + BTM_ACL_PKT_TYPES_MASK_NO_3_DH3 +
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
}
/* EDR 3 and 5 slot support? */ /* EDR 3 and 5 slot support? */
if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0]) if (HCI_EDR_ACL_2MPS_SUPPORTED(p->peer_lmp_features[HCI_EXT_FEATURES_PAGE_0])

View file

@ -66,7 +66,7 @@ extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr);
** bd_name - Name of the peer device. NULL if unknown. ** bd_name - Name of the peer device. NULL if unknown.
** dev_type - Remote device's device type. ** dev_type - Remote device's device type.
** addr_type - LE device address type. ** addr_type - LE device address type.
** auth_mode - auth mode ** auth_mode - auth mode
** **
** Returns TRUE if added OK, else FALSE ** Returns TRUE if added OK, else FALSE
** **
@ -887,8 +887,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
return BTM_SEC_OK; return BTM_SEC_OK;
} }
if (security_required & BTM_SEC_OUT_MITM) if (security_required & BTM_SEC_OUT_MITM) {
auth_req |= BTM_LE_AUTH_REQ_MITM; auth_req |= BTM_LE_AUTH_REQ_MITM;
}
} }
else else
{ {
@ -898,8 +899,9 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
return BTM_SEC_OK; return BTM_SEC_OK;
} }
if (security_required & BTM_SEC_IN_MITM) if (security_required & BTM_SEC_IN_MITM) {
auth_req |= BTM_LE_AUTH_REQ_MITM; auth_req |= BTM_LE_AUTH_REQ_MITM;
}
} }
tBTM_BLE_SEC_REQ_ACT ble_sec_act = BTM_BLE_SEC_REQ_ACT_NONE; tBTM_BLE_SEC_REQ_ACT ble_sec_act = BTM_BLE_SEC_REQ_ACT_NONE;
@ -907,11 +909,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
BTM_TRACE_DEBUG ("%s ble_sec_act %d", __func__ , ble_sec_act); BTM_TRACE_DEBUG ("%s ble_sec_act %d", __func__ , ble_sec_act);
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD) if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_DISCARD) {
return BTM_SEC_ENC_PENDING; return BTM_SEC_ENC_PENDING;
}
if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE) if (ble_sec_act == BTM_BLE_SEC_REQ_ACT_NONE) {
return BTM_SEC_OK; return BTM_SEC_OK;
}
UINT8 sec_flag = 0; UINT8 sec_flag = 0;
BTM_GetSecurityFlagsByTransport(bdaddr, &sec_flag, BT_TRANSPORT_LE); BTM_GetSecurityFlagsByTransport(bdaddr, &sec_flag, BT_TRANSPORT_LE);
@ -920,11 +924,13 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
BOOLEAN is_key_mitm = FALSE; BOOLEAN is_key_mitm = FALSE;
if (sec_flag & (BTM_SEC_FLAG_ENCRYPTED| BTM_SEC_FLAG_LKEY_KNOWN)) if (sec_flag & (BTM_SEC_FLAG_ENCRYPTED| BTM_SEC_FLAG_LKEY_KNOWN))
{ {
if (sec_flag & BTM_SEC_FLAG_ENCRYPTED) if (sec_flag & BTM_SEC_FLAG_ENCRYPTED) {
is_link_encrypted = TRUE; is_link_encrypted = TRUE;
}
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) {
is_key_mitm = TRUE; is_key_mitm = TRUE;
}
} }
if (auth_req & BTM_LE_AUTH_REQ_MITM) if (auth_req & BTM_LE_AUTH_REQ_MITM)
@ -933,16 +939,18 @@ tBTM_SEC_ACTION btm_ble_determine_security_act(BOOLEAN is_originator, BD_ADDR bd
{ {
return BTM_SEC_ENCRYPT_MITM; return BTM_SEC_ENCRYPT_MITM;
} else { } else {
if (is_link_encrypted) if (is_link_encrypted) {
return BTM_SEC_OK; return BTM_SEC_OK;
else } else {
return BTM_SEC_ENCRYPT; return BTM_SEC_ENCRYPT;
}
} }
} else { } else {
if (is_link_encrypted) if (is_link_encrypted) {
return BTM_SEC_OK; return BTM_SEC_OK;
else } else {
return BTM_SEC_ENCRYPT_NO_MITM; return BTM_SEC_ENCRYPT_NO_MITM;
}
} }
return BTM_SEC_OK; return BTM_SEC_OK;
@ -1012,8 +1020,9 @@ BOOLEAN btm_ble_start_sec_check(BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_originat
break; break;
} }
if (ble_sec_act == BTM_BLE_SEC_NONE) if (ble_sec_act == BTM_BLE_SEC_NONE) {
return status; return status;
}
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE); tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bd_addr, BT_TRANSPORT_LE);
p_lcb->sec_act = sec_act; p_lcb->sec_act = sec_act;

View file

@ -312,9 +312,10 @@ void btm_ble_scan_pf_cmpl_cback(tBTM_VSC_CMPL *p_params)
if (HCI_SUCCESS == status) { if (HCI_SUCCESS == status) {
if (memcmp(&btm_ble_adv_filt_cb.cur_filter_target.bda, &na_bda, BD_ADDR_LEN) == 0) { if (memcmp(&btm_ble_adv_filt_cb.cur_filter_target.bda, &na_bda, BD_ADDR_LEN) == 0) {
btm_ble_cs_update_pf_counter(action, cond_type, NULL, num_avail); btm_ble_cs_update_pf_counter(action, cond_type, NULL, num_avail);
} else } else {
btm_ble_cs_update_pf_counter(action, cond_type, btm_ble_cs_update_pf_counter(action, cond_type,
&btm_ble_adv_filt_cb.cur_filter_target, num_avail); &btm_ble_adv_filt_cb.cur_filter_target, num_avail);
}
} }
/* send ADV PF operation complete */ /* send ADV PF operation complete */
@ -855,9 +856,10 @@ tBTM_STATUS btm_ble_update_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
len, len,
param, param,
btm_ble_scan_pf_cmpl_cback)) != BTM_NO_RESOURCES) { btm_ble_scan_pf_cmpl_cback)) != BTM_NO_RESOURCES) {
if (p_uuid_cond && p_uuid_cond->p_target_addr) if (p_uuid_cond && p_uuid_cond->p_target_addr) {
memcpy(&btm_ble_adv_filt_cb.cur_filter_target, p_uuid_cond->p_target_addr, memcpy(&btm_ble_adv_filt_cb.cur_filter_target, p_uuid_cond->p_target_addr,
sizeof(tBLE_BD_ADDR)); sizeof(tBLE_BD_ADDR));
}
else { else {
memset(&btm_ble_adv_filt_cb.cur_filter_target, 0, sizeof(tBLE_BD_ADDR)); memset(&btm_ble_adv_filt_cb.cur_filter_target, 0, sizeof(tBLE_BD_ADDR));
} }
@ -914,15 +916,17 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
/* clear manufactuer data filter */ /* clear manufactuer data filter */
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL, st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
BTM_BLE_PF_MANU_DATA, cb_evt, ref_value); BTM_BLE_PF_MANU_DATA, cb_evt, ref_value);
if (BTM_CMD_STARTED == st) if (BTM_CMD_STARTED == st) {
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_MANU_DATA, cb_evt, btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_MANU_DATA, cb_evt,
ref_value, NULL, NULL); ref_value, NULL, NULL);
}
/* clear local name filter */ /* clear local name filter */
st = btm_ble_update_pf_local_name(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL); st = btm_ble_update_pf_local_name(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
if (BTM_CMD_STARTED == st) if (BTM_CMD_STARTED == st) {
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_LOCAL_NAME, cb_evt, btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_LOCAL_NAME, cb_evt,
ref_value, NULL, NULL); ref_value, NULL, NULL);
}
/* update the counter for service data */ /* update the counter for service data */
st = btm_ble_update_srvc_data_change(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL); st = btm_ble_update_srvc_data_change(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL);
@ -936,16 +940,18 @@ tBTM_STATUS btm_ble_clear_scan_pf_filter(tBTM_BLE_SCAN_COND_OP action,
st = btm_ble_update_uuid_filter(BTM_BLE_SCAN_COND_CLEAR, filt_index, st = btm_ble_update_uuid_filter(BTM_BLE_SCAN_COND_CLEAR, filt_index,
BTM_BLE_PF_SRVC_SOL_UUID, NULL, cb_evt, ref_value); BTM_BLE_PF_SRVC_SOL_UUID, NULL, cb_evt, ref_value);
if (BTM_CMD_STARTED == st) if (BTM_CMD_STARTED == st) {
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SOL_UUID, cb_evt, btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SOL_UUID, cb_evt,
ref_value, NULL, NULL); ref_value, NULL, NULL);
}
/* clear service data filter */ /* clear service data filter */
st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL, st = btm_ble_update_pf_manu_data(BTM_BLE_SCAN_COND_CLEAR, filt_index, NULL,
BTM_BLE_PF_SRVC_DATA_PATTERN, cb_evt, ref_value); BTM_BLE_PF_SRVC_DATA_PATTERN, cb_evt, ref_value);
if (BTM_CMD_STARTED == st) if (BTM_CMD_STARTED == st) {
btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SRVC_DATA, cb_evt, btm_ble_advfilt_enq_op_q(action, BTM_BLE_META_PF_SRVC_DATA, cb_evt,
ref_value, NULL, NULL); ref_value, NULL, NULL);
}
} }
/* select feature based on control block settings */ /* select feature based on control block settings */
@ -1053,9 +1059,10 @@ tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, tBTM_BLE_PF_FILT_INDEX filt_i
if (cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_L_VERSION) { if (cmn_ble_vsc_cb.version_supported == BTM_VSC_CHIP_CAPABILITY_L_VERSION) {
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN; len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN;
} else } else {
len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN + len = BTM_BLE_ADV_FILT_META_HDR_LENGTH + BTM_BLE_ADV_FILT_FEAT_SELN_LEN +
BTM_BLE_ADV_FILT_TRACK_NUM; BTM_BLE_ADV_FILT_TRACK_NUM;
}
if ((st = BTM_VendorSpecificCommand (HCI_BLE_ADV_FILTER_OCF, if ((st = BTM_VendorSpecificCommand (HCI_BLE_ADV_FILTER_OCF,
(UINT8)len, (UINT8)len,

View file

@ -427,9 +427,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
if (0 == num_records) { if (0 == num_records) {
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records, btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
&p_data, &data_len); &p_data, &data_len);
if (NULL != ble_batchscan_cb.p_scan_rep_cback) if (NULL != ble_batchscan_cb.p_scan_rep_cback) {
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, num_records, ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, num_records,
data_len, p_data, status); data_len, p_data, status);
}
} else { } else {
if ((len - 4) > 0) { if ((len - 4) > 0) {
btm_ble_batchscan_enq_rep_data(report_format, num_records, p, len - 4); btm_ble_batchscan_enq_rep_data(report_format, num_records, p, len - 4);
@ -439,9 +440,10 @@ void btm_ble_batchscan_vsc_cmpl_cback (tBTM_VSC_CMPL *p_params)
btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records, btm_ble_batchscan_deq_rep_data(report_format, &ref_value, &num_records,
&p_data, &data_len); &p_data, &data_len);
/* Send whatever is available, in case of a command failure */ /* Send whatever is available, in case of a command failure */
if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data) if (NULL != ble_batchscan_cb.p_scan_rep_cback && NULL != p_data) {
ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format, ble_batchscan_cb.p_scan_rep_cback(ref_value, report_format,
num_records, data_len, p_data, status); num_records, data_len, p_data, status);
}
} }
} }
} }

View file

@ -62,9 +62,10 @@ void btm_ble_cont_energy_cmpl_cback (tBTM_VSC_CMPL *p_params)
BTM_TRACE_DEBUG("energy_info status=%d,tx_t=%u, rx_t=%u, ener_used=%u, idle_t=%u", BTM_TRACE_DEBUG("energy_info status=%d,tx_t=%u, rx_t=%u, ener_used=%u, idle_t=%u",
status, total_tx_time, total_rx_time, total_energy_used, total_idle_time); status, total_tx_time, total_rx_time, total_energy_used, total_idle_time);
if (NULL != ble_energy_info_cb.p_ener_cback) if (NULL != ble_energy_info_cb.p_ener_cback) {
ble_energy_info_cb.p_ener_cback(total_tx_time, total_rx_time, total_idle_time, ble_energy_info_cb.p_ener_cback(total_tx_time, total_rx_time, total_idle_time,
total_energy_used, status); total_energy_used, status);
}
return; return;
} }

View file

@ -280,9 +280,10 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy)
/* if adv active, stop and restart */ /* if adv active, stop and restart */
btm_ble_stop_adv (); btm_ble_stop_adv ();
if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE) if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE) {
p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type, p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type,
&p_cb->adv_addr_type); &p_cb->adv_addr_type);
}
btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min : btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min :
BTM_BLE_GAP_ADV_SLOW_INT), BTM_BLE_GAP_ADV_SLOW_INT),
@ -736,7 +737,7 @@ void BTM_VendorHciEchoCmdTest(uint8_t echo)
{ {
BTM_VendorSpecificCommand (HCI_VENDOR_COMMON_ECHO_CMD_OPCODE, BTM_VendorSpecificCommand (HCI_VENDOR_COMMON_ECHO_CMD_OPCODE,
1, 1,
&echo, &echo,
BTM_VendorHciEchoCmdCallback); BTM_VendorHciEchoCmdCallback);
} }
@ -1252,7 +1253,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
} }
if(own_bda_type == BLE_ADDR_RANDOM) { if(own_bda_type == BLE_ADDR_RANDOM) {
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
//close privacy //close privacy
#if BLE_PRIVACY_SPT == TRUE #if BLE_PRIVACY_SPT == TRUE
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
@ -1261,9 +1262,9 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
#endif #endif
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
// set address to controller // set address to controller
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { } else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
@ -1273,7 +1274,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
if(adv_cb) { if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
} }
return BTM_ILLEGAL_VALUE; return BTM_ILLEGAL_VALUE;
} }
} else if(own_bda_type == BLE_ADDR_PUBLIC_ID || own_bda_type == BLE_ADDR_RANDOM_ID) { } else if(own_bda_type == BLE_ADDR_PUBLIC_ID || own_bda_type == BLE_ADDR_RANDOM_ID) {
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
@ -1288,7 +1289,7 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
if(adv_cb) { if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
} }
return BTM_ILLEGAL_VALUE; return BTM_ILLEGAL_VALUE;
} }
#endif #endif
if(own_bda_type == BLE_ADDR_PUBLIC_ID) { if(own_bda_type == BLE_ADDR_PUBLIC_ID) {
@ -1305,17 +1306,17 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
if(adv_cb) { if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
} }
return BTM_ILLEGAL_VALUE; return BTM_ILLEGAL_VALUE;
} }
} }
} }
} else { } else {
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
} }
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) { !BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n"); BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
if(adv_cb) { if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
} }
@ -1370,7 +1371,6 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
p_dir_bda->bda, p_dir_bda->bda,
chnl_map, chnl_map,
p_cb->afp); p_cb->afp);
return btm_ble_start_adv(); return btm_ble_start_adv();
} }
@ -1490,11 +1490,11 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
BTM_BleConfigPrivacy(FALSE, NULL); BTM_BleConfigPrivacy(FALSE, NULL);
} }
#endif #endif
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN);
// set address to controller // set address to controller
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr);
} else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { } else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
@ -1504,12 +1504,12 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
} }
BTM_TRACE_ERROR ("No random address yet, please set random address and try\n"); BTM_TRACE_ERROR ("No random address yet, please set random address and try\n");
return; return;
} }
} else if(addr_type_own == BLE_ADDR_PUBLIC_ID || addr_type_own == BLE_ADDR_RANDOM_ID) { } else if(addr_type_own == BLE_ADDR_PUBLIC_ID || addr_type_own == BLE_ADDR_RANDOM_ID) {
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) {
addr_type_own = BLE_ADDR_RANDOM; addr_type_own = BLE_ADDR_RANDOM;
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN);
btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr);
} else { } else {
@ -1519,12 +1519,12 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
if (scan_setup_status_cback != NULL) { if (scan_setup_status_cback != NULL) {
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
} }
return; return;
} }
#endif #endif
if(addr_type_own == BLE_ADDR_PUBLIC_ID) { if(addr_type_own == BLE_ADDR_PUBLIC_ID) {
addr_type_own = BLE_ADDR_PUBLIC; addr_type_own = BLE_ADDR_PUBLIC;
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
} else { } else {
//own_bda_type == BLE_ADDR_RANDOM_ID //own_bda_type == BLE_ADDR_RANDOM_ID
if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) {
@ -1537,12 +1537,12 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
if (scan_setup_status_cback != NULL) { if (scan_setup_status_cback != NULL) {
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
} }
return; return;
} }
} }
} }
} else { } else {
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC;
} }
/* If not supporting extended scan support, use the older range for checking */ /* If not supporting extended scan support, use the older range for checking */
@ -1661,7 +1661,7 @@ tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_le
** Returns status ** Returns status
** **
*******************************************************************************/ *******************************************************************************/
tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info, tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info,
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb) tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK update_exceptional_list_cmp_cb)
{ {
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb; tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
@ -1774,8 +1774,9 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
*******************************************************************************/ *******************************************************************************/
tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr) tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr)
{ {
if (rand_addr == NULL) if (rand_addr == NULL) {
return BTM_SET_STATIC_RAND_ADDR_FAIL; return BTM_SET_STATIC_RAND_ADDR_FAIL;
}
if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) { if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) {
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state); BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
@ -1842,7 +1843,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type)
memset(addr, 0, BD_ADDR_LEN); memset(addr, 0, BD_ADDR_LEN);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/******************************************************************************* /*******************************************************************************
@ -2825,7 +2826,7 @@ void btm_ble_cache_adv_data(BD_ADDR bda, tBTM_INQ_RESULTS *p_cur, UINT8 data_len
memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX); memset(p_le_inq_cb->adv_data_cache, 0, BTM_BLE_CACHE_ADV_DATA_MAX);
p_cur->adv_data_len = 0; p_cur->adv_data_len = 0;
p_cur->scan_rsp_len = 0; p_cur->scan_rsp_len = 0;
} }
//Clear the adv cache if the addresses are not equal //Clear the adv cache if the addresses are not equal
if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) { if(memcmp(bda, p_le_inq_cb->adv_addr, BD_ADDR_LEN) != 0) {
@ -3279,7 +3280,7 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
temp_addr_type = addr_type; temp_addr_type = addr_type;
memcpy(temp_bda, bda, BD_ADDR_LEN); memcpy(temp_bda, bda, BD_ADDR_LEN);
/* map address to security record */ /* map address to security record */
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE); match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
@ -3402,13 +3403,13 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
0x02 Scannable undirected advertising (ADV_SCAN_IND) 0x02 Scannable undirected advertising (ADV_SCAN_IND)
0x03 Non connectable undirected advertising (ADV_NONCONN_IND) 0x03 Non connectable undirected advertising (ADV_NONCONN_IND)
0x04 Scan Response (SCAN_RSP) 0x04 Scan Response (SCAN_RSP)
0x05-0xFF Reserved for future use 0x05-0xFF Reserved for future use
*/ */
//if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer //if scan duplicate is enabled, the adv packet without scan response is allowed to report to higher layer
if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) { if(p_le_inq_cb->scan_duplicate_filter == BTM_BLE_SCAN_DUPLICATE_ENABLE) {
/* /*
Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer. Bluedroid will put the advertising packet and scan response into a packet and send it to the higher layer.
If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising If two advertising packets are not with the same address, or can't be combined into a packet, then the first advertising
packet will be discarded. So we added the following judgment: packet will be discarded. So we added the following judgment:
1. For different addresses, send the last advertising packet to higher layer 1. For different addresses, send the last advertising packet to higher layer
2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer 2. For same address and same advertising type (not scan response), send the last advertising packet to higher layer
@ -3756,7 +3757,7 @@ tBTM_STATUS btm_ble_start_adv(void)
btm_execute_wl_dev_operation(); btm_execute_wl_dev_operation();
btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV; btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV;
} }
/* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core, /* The complete event comes up immediately after the 'btsnd_hcic_ble_set_adv_enable' being called in dual core,
this causes the 'adv_mode' and 'state' not be set yet, so we set the state first */ this causes the 'adv_mode' and 'state' not be set yet, so we set the state first */
tBTM_BLE_GAP_STATE temp_state = p_cb->state; tBTM_BLE_GAP_STATE temp_state = p_cb->state;
UINT8 adv_mode = p_cb->adv_mode; UINT8 adv_mode = p_cb->adv_mode;
@ -4065,7 +4066,7 @@ BOOLEAN btm_ble_clear_topology_mask (tBTM_BLE_STATE_MASK request_state_mask)
** **
** Description Get BLE topology bit mask ** Description Get BLE topology bit mask
** **
** Returns state mask. ** Returns state mask.
** **
*******************************************************************************/ *******************************************************************************/
tBTM_BLE_STATE_MASK btm_ble_get_topology_mask (void) tBTM_BLE_STATE_MASK btm_ble_get_topology_mask (void)

View file

@ -521,9 +521,10 @@ tBTM_STATUS btm_ble_read_resolving_list_entry(tBTM_SEC_DEV_REC *p_dev_rec)
btm_ble_resolving_list_vsc_op_cmpl); btm_ble_resolving_list_vsc_op_cmpl);
} }
if (st == BTM_CMD_STARTED) if (st == BTM_CMD_STARTED) {
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr, btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
BTM_BLE_META_READ_IRK_ENTRY); BTM_BLE_META_READ_IRK_ENTRY);
}
return st; return st;
} }
@ -799,9 +800,10 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
} }
} }
if (rt) if (rt) {
btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr, btm_ble_enq_resolving_list_pending(p_dev_rec->bd_addr,
BTM_BLE_META_ADD_IRK_ENTRY); BTM_BLE_META_ADD_IRK_ENTRY);
}
/* if resolving list has been turned on, re-enable it */ /* if resolving list has been turned on, re-enable it */
if (rl_mask) { if (rl_mask) {

View file

@ -207,8 +207,9 @@ BOOLEAN BTM_SecDeleteDevice (BD_ADDR bd_addr, tBT_TRANSPORT transport)
extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr) extern void BTM_SecClearSecurityFlags (BD_ADDR bd_addr)
{ {
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr); tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(bd_addr);
if (p_dev_rec == NULL) if (p_dev_rec == NULL) {
return; return;
}
p_dev_rec->sec_flags = 0; p_dev_rec->sec_flags = 0;
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;

View file

@ -273,13 +273,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
btm_cb.btm_acl_pkt_types_supported = (BTM_ACL_PKT_TYPES_MASK_DH1 + btm_cb.btm_acl_pkt_types_supported = (BTM_ACL_PKT_TYPES_MASK_DH1 +
BTM_ACL_PKT_TYPES_MASK_DM1); BTM_ACL_PKT_TYPES_MASK_DM1);
if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features)) if (HCI_3_SLOT_PACKETS_SUPPORTED(p_features)) {
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH3 + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH3 +
BTM_ACL_PKT_TYPES_MASK_DM3); BTM_ACL_PKT_TYPES_MASK_DM3);
}
if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features)) if (HCI_5_SLOT_PACKETS_SUPPORTED(p_features)) {
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_DH5 +
BTM_ACL_PKT_TYPES_MASK_DM5); BTM_ACL_PKT_TYPES_MASK_DM5);
}
/* Add in EDR related ACL types */ /* Add in EDR related ACL types */
if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) { if (!HCI_EDR_ACL_2MPS_SUPPORTED(p_features)) {
@ -297,13 +299,15 @@ static void btm_decode_ext_features_page (UINT8 page_number, const UINT8 *p_feat
/* Check to see if 3 and 5 slot packets are available */ /* Check to see if 3 and 5 slot packets are available */
if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) || if (HCI_EDR_ACL_2MPS_SUPPORTED(p_features) ||
HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) { HCI_EDR_ACL_3MPS_SUPPORTED(p_features)) {
if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) if (!HCI_3_SLOT_EDR_ACL_SUPPORTED(p_features)) {
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH3 +
BTM_ACL_PKT_TYPES_MASK_NO_3_DH3); BTM_ACL_PKT_TYPES_MASK_NO_3_DH3);
}
if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) if (!HCI_5_SLOT_EDR_ACL_SUPPORTED(p_features)) {
btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 + btm_cb.btm_acl_pkt_types_supported |= (BTM_ACL_PKT_TYPES_MASK_NO_2_DH5 +
BTM_ACL_PKT_TYPES_MASK_NO_3_DH5); BTM_ACL_PKT_TYPES_MASK_NO_3_DH5);
}
} }
BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x", BTM_TRACE_DEBUG("Local supported ACL packet types: 0x%04x",

View file

@ -1042,9 +1042,10 @@ tBTM_STATUS BTM_ReadRemoteDeviceName (BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb
return btm_ble_read_remote_name(remote_bda, p_cur, p_cb); return btm_ble_read_remote_name(remote_bda, p_cur, p_cb);
} else } else
#endif #endif
{
return (btm_initiate_rem_name (remote_bda, p_cur, BTM_RMT_NAME_EXT, return (btm_initiate_rem_name (remote_bda, p_cur, BTM_RMT_NAME_EXT,
BTM_EXT_RMT_NAME_TIMEOUT, p_cb)); BTM_EXT_RMT_NAME_TIMEOUT, p_cb));
}
} }
/******************************************************************************* /*******************************************************************************
@ -1080,11 +1081,13 @@ tBTM_STATUS BTM_CancelRemoteDeviceName (void)
} }
} else } else
#endif #endif
{
if (btsnd_hcic_rmt_name_req_cancel (p_inq->remname_bda)) { if (btsnd_hcic_rmt_name_req_cancel (p_inq->remname_bda)) {
return (BTM_CMD_STARTED); return (BTM_CMD_STARTED);
} else { } else {
return (BTM_NO_RESOURCES); return (BTM_NO_RESOURCES);
} }
}
} else { } else {
return (BTM_WRONG_MODE); return (BTM_WRONG_MODE);
} }

View file

@ -887,7 +887,9 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
#ifdef APPL_AUTH_WRITE_EXCEPTION #ifdef APPL_AUTH_WRITE_EXCEPTION
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr)) if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
#endif #endif
{
btsnd_hcic_write_auth_enable (TRUE); btsnd_hcic_write_auth_enable (TRUE);
}
btm_cb.acl_disc_reason = 0xff ; btm_cb.acl_disc_reason = 0xff ;
@ -907,9 +909,10 @@ void BTM_PINCodeReply (BD_ADDR bd_addr, UINT8 res, UINT8 pin_len, UINT8 *p_pin,
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED; p_dev_rec->sec_flags &= ~BTM_SEC_LINK_KEY_AUTHED;
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_ERR_AUTH_FAILURE); p_dev_rec->sec_bd_name, HCI_ERR_AUTH_FAILURE);
}
} }
return; return;
} }
@ -1396,7 +1399,9 @@ tBTM_STATUS BTM_SetEncryption (BD_ADDR bd_addr, tBT_TRANSPORT transport, tBTM_SE
} }
} else } else
#endif #endif
{
rc = btm_sec_execute_procedure (p_dev_rec); rc = btm_sec_execute_procedure (p_dev_rec);
}
if (rc != BTM_CMD_STARTED && rc != BTM_BUSY) { if (rc != BTM_CMD_STARTED && rc != BTM_BUSY) {
if (p_callback) { if (p_callback) {
@ -2163,9 +2168,10 @@ tBTM_STATUS btm_sec_l2cap_access_req (BD_ADDR bd_addr, UINT16 psm, UINT16 handle
"rmt_support_for_sc : %d -> fail pairing\n", __FUNCTION__, "rmt_support_for_sc : %d -> fail pairing\n", __FUNCTION__,
local_supports_sc, local_supports_sc,
p_dev_rec->remote_supports_secure_connections); p_dev_rec->remote_supports_secure_connections);
if (p_callback) if (p_callback) {
(*p_callback) (bd_addr, transport, (void *)p_ref_data, (*p_callback) (bd_addr, transport, (void *)p_ref_data,
BTM_MODE4_LEVEL4_NOT_SUPPORTED); BTM_MODE4_LEVEL4_NOT_SUPPORTED);
}
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED); return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
} }
@ -2525,9 +2531,10 @@ tBTM_STATUS btm_sec_mx_access_request (BD_ADDR bd_addr, UINT16 psm, BOOLEAN is_o
"remote_support_for_sc %d: fail pairing\n", __FUNCTION__, "remote_support_for_sc %d: fail pairing\n", __FUNCTION__,
local_supports_sc, p_dev_rec->remote_supports_secure_connections); local_supports_sc, p_dev_rec->remote_supports_secure_connections);
if (p_callback) if (p_callback) {
(*p_callback) (bd_addr, transport, (void *)p_ref_data, (*p_callback) (bd_addr, transport, (void *)p_ref_data,
BTM_MODE4_LEVEL4_NOT_SUPPORTED); BTM_MODE4_LEVEL4_NOT_SUPPORTED);
}
return (BTM_MODE4_LEVEL4_NOT_SUPPORTED); return (BTM_MODE4_LEVEL4_NOT_SUPPORTED);
} }
@ -3013,9 +3020,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
/* Notify all clients waiting for name to be resolved */ /* Notify all clients waiting for name to be resolved */
for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) { for (i = 0; i < BTM_SEC_MAX_RMT_NAME_CALLBACKS; i++) {
if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) if (btm_cb.p_rmt_name_callback[i] && p_bd_addr) {
(*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class, (*btm_cb.p_rmt_name_callback[i])(p_bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name); p_dev_rec->sec_bd_name);
}
} }
} else { } else {
dev_class[0] = 0; dev_class[0] = 0;
@ -3100,9 +3108,10 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL); p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
}
} }
} }
return; return;
@ -3128,10 +3137,11 @@ void btm_sec_rmt_name_request_complete (UINT8 *p_bd_addr, UINT8 *p_bd_name, UINT
/* that some authentication has been completed */ /* that some authentication has been completed */
/* This is required when different entities receive link notification and auth complete */ /* This is required when different entities receive link notification and auth complete */
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) { if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)) {
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
p_dev_rec->dev_class, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_SUCCESS); p_dev_rec->sec_bd_name, HCI_SUCCESS);
}
} }
} }
@ -3907,10 +3917,11 @@ void btm_sec_auth_complete (UINT16 handle, UINT8 status)
/* User probably Disabled the keyboard while it was asleap. Let her try */ /* User probably Disabled the keyboard while it was asleap. Let her try */
if (btm_cb.api.p_auth_complete_callback) { if (btm_cb.api.p_auth_complete_callback) {
/* report the suthentication status */ /* report the suthentication status */
if (old_state != BTM_PAIR_STATE_IDLE) if (old_state != BTM_PAIR_STATE_IDLE) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
p_dev_rec->dev_class, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, status); p_dev_rec->sec_bd_name, status);
}
} }
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
@ -4181,9 +4192,10 @@ static void btm_sec_connect_after_reject_timeout (TIMER_LIST_ENT *p_tle)
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL); p_dev_rec->sec_bd_name, HCI_ERR_MEMORY_FULL);
}
} }
} }
#endif ///SMP_INCLUDED == TRUE #endif ///SMP_INCLUDED == TRUE
@ -4408,10 +4420,11 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
res = FALSE; res = FALSE;
} }
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
p_dev_rec->dev_class, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_SUCCESS); p_dev_rec->sec_bd_name, HCI_SUCCESS);
}
btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE); btm_sec_change_pairing_state (BTM_PAIR_STATE_IDLE);
@ -4717,9 +4730,10 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE) if (!(p_dev_rec->security_required & BTM_SEC_OUT_AUTHENTICATE)
/* for derived key, always send authentication callback for BR channel */ /* for derived key, always send authentication callback for BR channel */
|| ltk_derived_lk) { || ltk_derived_lk) {
if (btm_cb.api.p_auth_complete_callback) if (btm_cb.api.p_auth_complete_callback) {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_SUCCESS); p_dev_rec->sec_bd_name, HCI_SUCCESS);
}
} }
/* We will save link key only if the user authorized it - BTE report link key in all cases */ /* We will save link key only if the user authorized it - BTE report link key in all cases */
@ -4829,10 +4843,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda, (*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
NULL, NULL,
name, HCI_ERR_CONNECTION_TOUT); name, HCI_ERR_CONNECTION_TOUT);
} else } else {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
p_dev_rec->dev_class, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT); p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
}
} }
break; break;
@ -4888,10 +4903,11 @@ static void btm_sec_pairing_timeout (TIMER_LIST_ENT *p_tle)
(*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda, (*btm_cb.api.p_auth_complete_callback) (p_cb->pairing_bda,
NULL, NULL,
name, HCI_ERR_CONNECTION_TOUT); name, HCI_ERR_CONNECTION_TOUT);
} else } else {
(*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr, (*btm_cb.api.p_auth_complete_callback) (p_dev_rec->bd_addr,
p_dev_rec->dev_class, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT); p_dev_rec->sec_bd_name, HCI_ERR_CONNECTION_TOUT);
}
} }
break; break;
@ -5520,10 +5536,11 @@ static void btm_sec_collision_timeout (TIMER_LIST_ENT *p_tle)
*******************************************************************************/ *******************************************************************************/
static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec) static void btm_send_link_key_notif (tBTM_SEC_DEV_REC *p_dev_rec)
{ {
if (btm_cb.api.p_link_key_callback) if (btm_cb.api.p_link_key_callback) {
(*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class, (*btm_cb.api.p_link_key_callback) (p_dev_rec->bd_addr, p_dev_rec->dev_class,
p_dev_rec->sec_bd_name, p_dev_rec->link_key, p_dev_rec->sec_bd_name, p_dev_rec->link_key,
p_dev_rec->link_key_type); p_dev_rec->link_key_type);
}
} }
#endif ///SMP_INCLUDED == TRUE #endif ///SMP_INCLUDED == TRUE
@ -5703,7 +5720,9 @@ void btm_sec_dev_rec_cback_event (tBTM_SEC_DEV_REC *p_dev_rec, UINT8 res, BOOLEA
(*p_callback) (p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, p_dev_rec->p_ref_data, res); (*p_callback) (p_dev_rec->ble.pseudo_addr, BT_TRANSPORT_LE, p_dev_rec->p_ref_data, res);
} else } else
#endif #endif
{
(*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res); (*p_callback) (p_dev_rec->bd_addr, BT_TRANSPORT_BR_EDR, p_dev_rec->p_ref_data, res);
}
} }
#if (SMP_INCLUDED == TRUE) #if (SMP_INCLUDED == TRUE)
btm_sec_check_pending_reqs(); btm_sec_check_pending_reqs();
@ -5761,7 +5780,9 @@ static BOOLEAN btm_sec_check_prefetch_pin (tBTM_SEC_DEV_REC *p_dev_rec)
#ifdef APPL_AUTH_WRITE_EXCEPTION #ifdef APPL_AUTH_WRITE_EXCEPTION
if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr)) if (!(APPL_AUTH_WRITE_EXCEPTION)(p_dev_rec->bd_addr))
#endif #endif
{
btsnd_hcic_write_auth_enable (TRUE); btsnd_hcic_write_auth_enable (TRUE);
}
} }
} else { } else {
btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN); btm_sec_change_pairing_state (BTM_PAIR_STATE_WAIT_LOCAL_PIN);
@ -5913,8 +5934,9 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm)
static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport,
UINT8 encr_enable) UINT8 encr_enable)
{ {
if (fixed_queue_is_empty(btm_cb.sec_pending_q)) if (fixed_queue_is_empty(btm_cb.sec_pending_q)) {
return; return;
}
UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING; UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING;
list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q); list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q);

View file

@ -292,7 +292,7 @@ UINT16 GATTS_AddIncludeService (UINT16 service_handle, UINT16 include_svc_handle
** **
*******************************************************************************/ *******************************************************************************/
UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid, UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
tGATT_PERM perm, tGATT_CHAR_PROP property, tGATT_PERM perm, tGATT_CHAR_PROP property,
tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control) tGATT_ATTR_VAL *attr_val, tGATTS_ATTR_CONTROL *control)
{ {
tGATT_HDL_LIST_ELEM *p_decl; tGATT_HDL_LIST_ELEM *p_decl;
@ -311,7 +311,7 @@ UINT16 GATTS_AddCharacteristic (UINT16 service_handle, tBT_UUID *p_char_uuid,
return gatts_add_characteristic(&p_decl->svc_db, return gatts_add_characteristic(&p_decl->svc_db,
perm, perm,
property, property,
p_char_uuid, p_char_uuid,
attr_val, control); attr_val, control);
} }
/******************************************************************************* /*******************************************************************************
@ -734,7 +734,7 @@ tGATT_STATUS GATTS_SetAttributeValue(UINT16 attr_handle, UINT16 length, UINT8 *v
return GATT_INVALID_ATTR_LEN; return GATT_INVALID_ATTR_LEN;
} }
if ((p_decl = gatt_find_hdl_buffer_by_attr_handle(attr_handle)) == NULL) { if ((p_decl = gatt_find_hdl_buffer_by_attr_handle(attr_handle)) == NULL) {
GATT_TRACE_DEBUG("Service not created\n"); GATT_TRACE_DEBUG("Service not created\n");
return GATT_INVALID_HANDLE; return GATT_INVALID_HANDLE;
} }
@ -1161,9 +1161,10 @@ void GATT_SetIdleTimeout (BD_ADDR bd_addr, UINT16 idle_tout, tBT_TRANSPORT trans
if (p_tcb->att_lcid == L2CAP_ATT_CID) { if (p_tcb->att_lcid == L2CAP_ATT_CID) {
status = L2CA_SetFixedChannelTout (bd_addr, L2CAP_ATT_CID, idle_tout); status = L2CA_SetFixedChannelTout (bd_addr, L2CAP_ATT_CID, idle_tout);
if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) if (idle_tout == GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP) {
L2CA_SetIdleTimeoutByBdAddr(p_tcb->peer_bda, L2CA_SetIdleTimeoutByBdAddr(p_tcb->peer_bda,
GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, BT_TRANSPORT_LE); GATT_LINK_IDLE_TIMEOUT_WHEN_NO_APP, BT_TRANSPORT_LE);
}
} else { } else {
status = L2CA_SetIdleTimeout (p_tcb->att_lcid, idle_tout, FALSE); status = L2CA_SetIdleTimeout (p_tcb->att_lcid, idle_tout, FALSE);
} }
@ -1507,7 +1508,7 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb); srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
if (!srv_chg_ind_pending) { if (!srv_chg_ind_pending) {
status = gatt_send_srv_chg_ind(addr); status = gatt_send_srv_chg_ind(addr);
} else { } else {
status = GATT_BUSY; status = GATT_BUSY;
GATT_TRACE_DEBUG("discard srv chg - already has one in the queue"); GATT_TRACE_DEBUG("discard srv chg - already has one in the queue");

View file

@ -270,17 +270,21 @@ UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_ERTM_INFO *p_e
p_ccb->ertm_info = *p_ertm_info; p_ccb->ertm_info = *p_ertm_info;
/* Replace default indicators with the actual default pool */ /* Replace default indicators with the actual default pool */
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE; p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
}
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE; p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
}
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE; p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
}
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE; p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
}
p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size - p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
(L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN); (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
@ -416,17 +420,21 @@ BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 re
p_ccb->ertm_info = *p_ertm_info; p_ccb->ertm_info = *p_ertm_info;
/* Replace default indicators with the actual default pool */ /* Replace default indicators with the actual default pool */
if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.fcr_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE; p_ccb->ertm_info.fcr_rx_buf_size = L2CAP_FCR_RX_BUF_SIZE;
}
if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.fcr_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE; p_ccb->ertm_info.fcr_tx_buf_size = L2CAP_FCR_TX_BUF_SIZE;
}
if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.user_rx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE; p_ccb->ertm_info.user_rx_buf_size = L2CAP_USER_RX_BUF_SIZE;
}
if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) if (p_ccb->ertm_info.user_tx_buf_size == L2CAP_INVALID_ERM_BUF_SIZE) {
p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE; p_ccb->ertm_info.user_tx_buf_size = L2CAP_USER_TX_BUF_SIZE;
}
p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size - p_ccb->max_rx_mtu = p_ertm_info->user_rx_buf_size -
(L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN); (L2CAP_MIN_OFFSET + L2CAP_SDU_LEN_OFFSET + L2CAP_FCS_LEN);
@ -1340,8 +1348,9 @@ UINT16 L2CA_RegisterLECoc(UINT16 psm, tL2CAP_APPL_INFO *p_cb_info)
for (vpsm = 0x0080; vpsm < 0x0100; vpsm++) for (vpsm = 0x0080; vpsm < 0x0100; vpsm++)
{ {
p_rcb = l2cu_find_ble_rcb_by_psm(vpsm); p_rcb = l2cu_find_ble_rcb_by_psm(vpsm);
if (p_rcb == NULL) if (p_rcb == NULL) {
break; break;
}
} }
L2CAP_TRACE_API("%s Real PSM: 0x%04x Virtual PSM: 0x%04x", __func__, psm, vpsm); L2CAP_TRACE_API("%s Real PSM: 0x%04x Virtual PSM: 0x%04x", __func__, psm, vpsm);
@ -1390,20 +1399,24 @@ void L2CA_DeregisterLECoc(UINT16 psm)
tL2C_LCB *p_lcb = &l2cb.lcb_pool[0]; tL2C_LCB *p_lcb = &l2cb.lcb_pool[0];
for (int i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++) for (int i = 0; i < MAX_L2CAP_LINKS; i++, p_lcb++)
{ {
if (!p_lcb->in_use || p_lcb->transport != BT_TRANSPORT_LE) if (!p_lcb->in_use || p_lcb->transport != BT_TRANSPORT_LE) {
continue; continue;
}
tL2C_CCB *p_ccb = p_lcb->ccb_queue.p_first_ccb; tL2C_CCB *p_ccb = p_lcb->ccb_queue.p_first_ccb;
if ((p_ccb == NULL) || (p_lcb->link_state == LST_DISCONNECTING)) if ((p_ccb == NULL) || (p_lcb->link_state == LST_DISCONNECTING)) {
continue; continue;
}
if (p_ccb->in_use && if (p_ccb->in_use &&
(p_ccb->chnl_state == CST_W4_L2CAP_DISCONNECT_RSP || (p_ccb->chnl_state == CST_W4_L2CAP_DISCONNECT_RSP ||
p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP)) p_ccb->chnl_state == CST_W4_L2CA_DISCONNECT_RSP)) {
continue; continue;
}
if (p_ccb->p_rcb == p_rcb) if (p_ccb->p_rcb == p_rcb) {
l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_REQ, NULL); l2c_csm_execute(p_ccb, L2CEVT_L2CA_DISCONNECT_REQ, NULL);
}
} }
l2cu_release_rcb (p_rcb); l2cu_release_rcb (p_rcb);
@ -1473,8 +1486,9 @@ UINT16 L2CA_ConnectLECocReq(UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p
p_ccb->p_rcb = p_rcb; p_ccb->p_rcb = p_rcb;
/* Save the configuration */ /* Save the configuration */
if (p_cfg) if (p_cfg) {
memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO)); memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO));
}
/* If link is up, start the L2CAP connection */ /* If link is up, start the L2CAP connection */
if (p_lcb->link_state == LST_CONNECTED) if (p_lcb->link_state == LST_CONNECTED)
@ -1549,8 +1563,9 @@ BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 r
return FALSE; return FALSE;
} }
if (p_cfg) if (p_cfg) {
memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO)); memcpy(&p_ccb->local_conn_cfg, p_cfg, sizeof(tL2CAP_LE_CFG_INFO));
}
if (result == L2CAP_CONN_OK) if (result == L2CAP_CONN_OK)
l2c_csm_execute (p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL); l2c_csm_execute (p_ccb, L2CEVT_L2CA_CONNECT_RSP, NULL);
@ -1589,8 +1604,9 @@ BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg)
return FALSE; return FALSE;
} }
if (peer_cfg != NULL) if (peer_cfg != NULL) {
memcpy(peer_cfg, &p_ccb->peer_conn_cfg, sizeof(tL2CAP_LE_CFG_INFO)); memcpy(peer_cfg, &p_ccb->peer_conn_cfg, sizeof(tL2CAP_LE_CFG_INFO));
}
return TRUE; return TRUE;
} }
@ -1675,7 +1691,9 @@ BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda, tBLE_ADDR_TYPE
peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask; peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask;
} else } else
#endif #endif
{
peer_channel_mask = p_lcb->peer_chnl_mask[0]; peer_channel_mask = p_lcb->peer_chnl_mask[0];
}
// Check for supported channel // Check for supported channel
if (!(peer_channel_mask & (1 << fixed_cid))) { if (!(peer_channel_mask & (1 << fixed_cid))) {
@ -1795,7 +1813,9 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask; peer_channel_mask = l2cb.l2c_ble_fixed_chnls_mask;
} else } else
#endif #endif
{
peer_channel_mask = p_lcb->peer_chnl_mask[0]; peer_channel_mask = p_lcb->peer_chnl_mask[0];
}
if ((peer_channel_mask & (1 << fixed_cid)) == 0) { if ((peer_channel_mask & (1 << fixed_cid)) == 0) {
L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid); L2CAP_TRACE_WARNING ("L2CA_SendFixedChnlData() - peer does not support fixed chnl: 0x%04x", fixed_cid);

View file

@ -1260,8 +1260,9 @@ UINT32 CalConnectParamTimeout(tL2C_LCB *p_lcb)
*******************************************************************************/ *******************************************************************************/
void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb) void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb)
{ {
if (!p_ccb) if (!p_ccb) {
return; return;
}
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE) if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
{ {
@ -1285,8 +1286,9 @@ void l2cble_credit_based_conn_req (tL2C_CCB *p_ccb)
*******************************************************************************/ *******************************************************************************/
void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result) void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result)
{ {
if (!p_ccb) if (!p_ccb) {
return; return;
}
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE) if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
{ {
@ -1310,8 +1312,9 @@ void l2cble_credit_based_conn_res (tL2C_CCB *p_ccb, UINT16 result)
*******************************************************************************/ *******************************************************************************/
void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value) void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value)
{ {
if (!p_ccb) if (!p_ccb) {
return; return;
}
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE) if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
{ {
@ -1337,8 +1340,9 @@ void l2cble_send_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value)
void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb) void l2cble_send_peer_disc_req(tL2C_CCB *p_ccb)
{ {
L2CAP_TRACE_DEBUG ("%s",__func__); L2CAP_TRACE_DEBUG ("%s",__func__);
if (!p_ccb) if (!p_ccb) {
return; return;
}
if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE) if (p_ccb->p_lcb && p_ccb->p_lcb->transport != BT_TRANSPORT_LE)
{ {
@ -1396,8 +1400,9 @@ void l2cble_sec_comp(BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data,
if (sec_act == BTM_SEC_ENCRYPT_MITM) if (sec_act == BTM_SEC_ENCRYPT_MITM)
{ {
BTM_GetSecurityFlagsByTransport(p_bda, &sec_flag, transport); BTM_GetSecurityFlagsByTransport(p_bda, &sec_flag, transport);
if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) if (sec_flag & BTM_SEC_FLAG_LKEY_AUTHED) {
(*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status); (*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status);
}
else else
{ {
L2CAP_TRACE_DEBUG ("%s MITM Protection Not present", __func__); L2CAP_TRACE_DEBUG ("%s MITM Protection Not present", __func__);
@ -1425,11 +1430,12 @@ void l2cble_sec_comp(BD_ADDR p_bda, tBT_TRANSPORT transport, void *p_ref_data,
{ {
p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q); p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q);
if (status != BTM_SUCCESS) if (status != BTM_SUCCESS) {
(*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status); (*(p_buf->p_callback))(p_bda, BT_TRANSPORT_LE, p_buf->p_ref_data, status);
else } else {
l2ble_sec_access_req(p_bda, p_buf->psm, p_buf->is_originator, l2ble_sec_access_req(p_bda, p_buf->psm, p_buf->is_originator,
p_buf->p_callback, p_buf->p_ref_data); p_buf->p_callback, p_buf->p_ref_data);
}
osi_free(p_buf); osi_free(p_buf);
} }

View file

@ -837,10 +837,10 @@ static void l2c_csm_config (tL2C_CCB *p_ccb, UINT16 event, void *p_data)
if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL && if (p_ccb->local_cid >= L2CAP_FIRST_FIXED_CHNL &&
p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) { p_ccb->local_cid <= L2CAP_LAST_FIXED_CHNL) {
if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) { if (p_ccb->local_cid < L2CAP_BASE_APPL_CID) {
if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) if (l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) {
(*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) (*l2cb.fixed_reg[p_ccb->local_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
(p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, (BT_HDR *)p_data); (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, (BT_HDR *)p_data);
else { } else {
osi_free (p_data); osi_free (p_data);
} }
break; break;

View file

@ -246,13 +246,13 @@ void l2c_fcr_cleanup (tL2C_CCB *p_ccb)
fixed_queue_free(p_fcrb->retrans_q, osi_free_func); fixed_queue_free(p_fcrb->retrans_q, osi_free_func);
p_fcrb->retrans_q = NULL; p_fcrb->retrans_q = NULL;
btu_free_quick_timer (&p_fcrb->ack_timer); btu_free_quick_timer (&p_fcrb->ack_timer);
memset(&p_fcrb->ack_timer, 0, sizeof(TIMER_LIST_ENT)); memset(&p_fcrb->ack_timer, 0, sizeof(TIMER_LIST_ENT));
btu_free_quick_timer (&p_ccb->fcrb.mon_retrans_timer); btu_free_quick_timer (&p_ccb->fcrb.mon_retrans_timer);
memset(&p_fcrb->mon_retrans_timer, 0, sizeof(TIMER_LIST_ENT)); memset(&p_fcrb->mon_retrans_timer, 0, sizeof(TIMER_LIST_ENT));
#if (L2CAP_ERTM_STATS == TRUE) #if (L2CAP_ERTM_STATS == TRUE)
if ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) ) { if ( (p_ccb->local_cid >= L2CAP_BASE_APPL_CID) && (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) ) {
UINT32 dur = osi_time_get_os_boottime_ms() - p_ccb->fcrb.connect_tick_count; UINT32 dur = osi_time_get_os_boottime_ms() - p_ccb->fcrb.connect_tick_count;
@ -1382,7 +1382,9 @@ static BOOLEAN do_sar_reassembly (tL2C_CCB *p_ccb, BT_HDR *p_buf, UINT16 ctrl_wo
(p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, p_buf); (p_ccb->local_cid, p_ccb->p_lcb->remote_bd_addr, p_buf);
} else } else
#endif #endif
{
l2c_csm_execute (p_ccb, L2CEVT_L2CAP_DATA, p_buf); l2c_csm_execute (p_ccb, L2CEVT_L2CAP_DATA, p_buf);
}
} }
return (packet_ok); return (packet_ok);
@ -2149,8 +2151,9 @@ static void l2c_fcr_collect_ack_delay (tL2C_CCB *p_ccb, UINT8 num_bufs_acked)
/* update sum, max and min of round trip delay of acking */ /* update sum, max and min of round trip delay of acking */
list_t *list = NULL; list_t *list = NULL;
if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) if (! fixed_queue_is_empty(p_ccb->fcrb.waiting_for_ack_q)) {
list = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q); list = fixed_queue_get_list(p_ccb->fcrb.waiting_for_ack_q);
}
if (list != NULL) { if (list != NULL) {
for (const list_node_t *node = list_begin(list), xx = 0; for (const list_node_t *node = list_begin(list), xx = 0;
(node != list_end(list)) && (xx < num_bufs_acked); (node != list_end(list)) && (xx < num_bufs_acked);

View file

@ -191,11 +191,11 @@ BOOLEAN l2c_link_hci_conn_comp (UINT8 status, UINT16 handle, BD_ADDR p_bda)
l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE); l2cu_send_peer_info_req (p_lcb, L2CAP_EXTENDED_FEATURES_INFO_TYPE);
/* Tell BTM Acl management about the link */ /* Tell BTM Acl management about the link */
if ((p_dev_info = btm_find_dev (p_bda)) != NULL) if ((p_dev_info = btm_find_dev (p_bda)) != NULL) {
btm_acl_created (ci.bd_addr, p_dev_info->dev_class, btm_acl_created (ci.bd_addr, p_dev_info->dev_class,
p_dev_info->sec_bd_name, handle, p_dev_info->sec_bd_name, handle,
p_lcb->link_role, BT_TRANSPORT_BR_EDR); p_lcb->link_role, BT_TRANSPORT_BR_EDR);
else { } else {
btm_acl_created (ci.bd_addr, NULL, NULL, handle, p_lcb->link_role, BT_TRANSPORT_BR_EDR); btm_acl_created (ci.bd_addr, NULL, NULL, handle, p_lcb->link_role, BT_TRANSPORT_BR_EDR);
} }
@ -399,8 +399,10 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_BR_EDR) if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
#endif #endif
{
/* Tell SCO management to drop any SCOs on this ACL */ /* Tell SCO management to drop any SCOs on this ACL */
btm_sco_acl_removed (p_lcb->remote_bd_addr); btm_sco_acl_removed (p_lcb->remote_bd_addr);
}
#endif #endif
/* If waiting for disconnect and reconnect is pending start the reconnect now /* If waiting for disconnect and reconnect is pending start the reconnect now
@ -657,7 +659,7 @@ void l2c_info_timeout (tL2C_LCB *p_lcb)
} }
} }
} }
#endif ///CLASSIC_BT_INCLUDED == TRUE #endif ///CLASSIC_BT_INCLUDED == TRUE
} }
} }
@ -998,7 +1000,9 @@ void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf)
l2cb.ble_check_round_robin = TRUE; l2cb.ble_check_round_robin = TRUE;
} else } else
#endif #endif
{
l2cb.check_round_robin = TRUE; l2cb.check_round_robin = TRUE;
}
} }
} }

View file

@ -237,7 +237,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
/* nothing to do */ /* nothing to do */
} else } else
#endif #endif
{
osi_free (p_msg); osi_free (p_msg);
}
} }
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID) { else if (rcv_cid == L2CAP_BLE_SIGNALLING_CID) {
@ -263,9 +265,10 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
#if (CLASSIC_BT_INCLUDED == TRUE) #if (CLASSIC_BT_INCLUDED == TRUE)
l2c_fcr_proc_pdu (p_ccb, p_msg); l2c_fcr_proc_pdu (p_ccb, p_msg);
#endif ///CLASSIC_BT_INCLUDED == TRUE #endif ///CLASSIC_BT_INCLUDED == TRUE
} else } else {
(*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb) (*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
(rcv_cid, p_lcb->remote_bd_addr, p_msg); (rcv_cid, p_lcb->remote_bd_addr, p_msg);
}
} else { } else {
osi_free (p_msg); osi_free (p_msg);
} }

View file

@ -151,8 +151,10 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
if (p_lcb->transport == BT_TRANSPORT_BR_EDR) if (p_lcb->transport == BT_TRANSPORT_BR_EDR)
#endif #endif
{
/* Release all SCO links */ /* Release all SCO links */
btm_remove_sco_links(p_lcb->remote_bd_addr); btm_remove_sco_links(p_lcb->remote_bd_addr);
}
#endif #endif
if (p_lcb->sent_not_acked > 0) { if (p_lcb->sent_not_acked > 0) {
@ -189,12 +191,13 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
} }
/* Tell BTM Acl management the link was removed */ /* Tell BTM Acl management the link was removed */
if ((p_lcb->link_state == LST_CONNECTED) || (p_lcb->link_state == LST_DISCONNECTING)) if ((p_lcb->link_state == LST_CONNECTED) || (p_lcb->link_state == LST_DISCONNECTING)) {
#if (BLE_INCLUDED == TRUE) #if (BLE_INCLUDED == TRUE)
btm_acl_removed (p_lcb->remote_bd_addr, p_lcb->transport); btm_acl_removed (p_lcb->remote_bd_addr, p_lcb->transport);
#else #else
btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_BR_EDR); btm_acl_removed (p_lcb->remote_bd_addr, BT_TRANSPORT_BR_EDR);
#endif #endif
}
/* Release any held buffers */ /* Release any held buffers */
if (p_lcb->link_xmit_data_q) { if (p_lcb->link_xmit_data_q) {
@ -246,8 +249,9 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
while (!fixed_queue_is_empty(p_lcb->le_sec_pending_q)) while (!fixed_queue_is_empty(p_lcb->le_sec_pending_q))
{ {
tL2CAP_SEC_DATA *p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q); tL2CAP_SEC_DATA *p_buf = (tL2CAP_SEC_DATA*) fixed_queue_dequeue(p_lcb->le_sec_pending_q);
if (p_buf->p_callback) if (p_buf->p_callback) {
p_buf->p_callback(p_lcb->remote_bd_addr, p_lcb->transport, p_buf->p_ref_data, BTM_DEV_RESET); p_buf->p_callback(p_lcb->remote_bd_addr, p_lcb->transport, p_buf->p_ref_data, BTM_DEV_RESET);
}
osi_free(p_buf); osi_free(p_buf);
} }
fixed_queue_free(p_lcb->le_sec_pending_q, NULL); fixed_queue_free(p_lcb->le_sec_pending_q, NULL);
@ -1880,8 +1884,9 @@ tL2C_RCB *l2cu_find_ble_rcb_by_psm (UINT16 psm)
for (xx = 0; xx < BLE_MAX_L2CAP_CLIENTS; xx++, p_rcb++) for (xx = 0; xx < BLE_MAX_L2CAP_CLIENTS; xx++, p_rcb++)
{ {
if ((p_rcb->in_use) && (p_rcb->psm == psm)) if ((p_rcb->in_use) && (p_rcb->psm == psm)) {
return (p_rcb); return (p_rcb);
}
} }
/* If here, no match found */ /* If here, no match found */
@ -2862,7 +2867,7 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb)
#endif #endif
} }
} else if ( (peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL))) } else if ( (peer_channel_mask & (1 << (xx + L2CAP_FIRST_FIXED_CHNL)))
&& (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) ) && (l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb != NULL) ) {
#if BLE_INCLUDED == TRUE #if BLE_INCLUDED == TRUE
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport); p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, p_lcb->transport);
@ -2870,6 +2875,7 @@ void l2cu_process_fixed_disc_cback (tL2C_LCB *p_lcb)
(*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL, (*l2cb.fixed_reg[xx].pL2CA_FixedConn_Cb)(xx + L2CAP_FIRST_FIXED_CHNL,
p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR); p_lcb->remote_bd_addr, FALSE, p_lcb->disc_reason, BT_TRANSPORT_BR_EDR);
#endif #endif
}
} }
#endif #endif
} }
@ -2960,8 +2966,9 @@ void l2cu_send_peer_ble_credit_based_conn_req (tL2C_CCB *p_ccb)
UINT16 mps; UINT16 mps;
UINT16 initial_credit; UINT16 initial_credit;
if (!p_ccb) if (!p_ccb) {
return; return;
}
p_lcb = p_ccb->p_lcb; p_lcb = p_ccb->p_lcb;
/* Create an identifier for this packet */ /* Create an identifier for this packet */
@ -3082,8 +3089,9 @@ void l2cu_send_peer_ble_flow_control_credit(tL2C_CCB *p_ccb, UINT16 credit_value
UINT8 *p; UINT8 *p;
tL2C_LCB *p_lcb = NULL; tL2C_LCB *p_lcb = NULL;
if (!p_ccb) if (!p_ccb) {
return; return;
}
p_lcb = p_ccb->p_lcb; p_lcb = p_ccb->p_lcb;
/* Create an identifier for this packet */ /* Create an identifier for this packet */
@ -3125,8 +3133,9 @@ void l2cu_send_peer_ble_credit_based_disconn_req(tL2C_CCB *p_ccb)
tL2C_LCB *p_lcb = NULL; tL2C_LCB *p_lcb = NULL;
L2CAP_TRACE_DEBUG ("%s",__func__); L2CAP_TRACE_DEBUG ("%s",__func__);
if (!p_ccb) if (!p_ccb) {
return; return;
}
p_lcb = p_ccb->p_lcb; p_lcb = p_ccb->p_lcb;
/* Create an identifier for this packet */ /* Create an identifier for this packet */

View file

@ -1185,8 +1185,9 @@ int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len, UINT16 *p_len)
while (max_len) while (max_len)
{ {
p_buf = (BT_HDR *)fixed_queue_try_peek_first(p_port->rx.queue); p_buf = (BT_HDR *)fixed_queue_try_peek_first(p_port->rx.queue);
if (p_buf == NULL) if (p_buf == NULL){
break; break;
}
if (p_buf->len > max_len) { if (p_buf->len > max_len) {
memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, max_len); memcpy (p_data, (UINT8 *)(p_buf + 1) + p_buf->offset, max_len);

View file

@ -899,11 +899,11 @@ UINT16 SDP_DiDiscover( BD_ADDR remote_device, tSDP_DISCOVERY_DB *p_db,
init_uuid.len = 2; init_uuid.len = 2;
init_uuid.uu.uuid16 = di_uuid; init_uuid.uu.uuid16 = di_uuid;
if ( SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL) ) if ( SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL) ) {
if ( SDP_ServiceSearchRequest(remote_device, p_db, p_cb) ) { if ( SDP_ServiceSearchRequest(remote_device, p_db, p_cb) ) {
result = SDP_SUCCESS; result = SDP_SUCCESS;
} }
}
return result; return result;
#else #else
return SDP_DI_DISC_FAILED; return SDP_DI_DISC_FAILED;

View file

@ -467,12 +467,13 @@ static void sdp_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed)
SDP_TRACE_EVENT ("SDP - Rcvd L2CAP disc, CID: 0x%x\n", l2cap_cid); SDP_TRACE_EVENT ("SDP - Rcvd L2CAP disc, CID: 0x%x\n", l2cap_cid);
#if SDP_CLIENT_ENABLED == TRUE #if SDP_CLIENT_ENABLED == TRUE
/* Tell the user if he has a callback */ /* Tell the user if he has a callback */
if (p_ccb->p_cb) if (p_ccb->p_cb) {
(*p_ccb->p_cb) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ? (*p_ccb->p_cb) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ?
SDP_SUCCESS : SDP_CONN_FAILED)); SDP_SUCCESS : SDP_CONN_FAILED));
else if (p_ccb->p_cb2) } else if (p_ccb->p_cb2) {
(*p_ccb->p_cb2) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ? (*p_ccb->p_cb2) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ?
SDP_SUCCESS : SDP_CONN_FAILED), p_ccb->user_data); SDP_SUCCESS : SDP_CONN_FAILED), p_ccb->user_data);
}
#endif #endif
sdpu_release_ccb (p_ccb); sdpu_release_ccb (p_ccb);

View file

@ -242,6 +242,7 @@ UINT8 *sdpu_build_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr)
} else } else
#endif /* 0xFFFF - 0xFF */ #endif /* 0xFFFF - 0xFF */
{
#if (SDP_MAX_ATTR_LEN > 0xFF) #if (SDP_MAX_ATTR_LEN > 0xFF)
if (p_attr->len > 0xFF) { if (p_attr->len > 0xFF) {
UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_WORD); UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_WORD);
@ -253,7 +254,7 @@ UINT8 *sdpu_build_attrib_entry (UINT8 *p_out, tSDP_ATTRIBUTE *p_attr)
UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_BYTE); UINT8_TO_BE_STREAM (p_out, (p_attr->type << 3) | SIZE_IN_NEXT_BYTE);
UINT8_TO_BE_STREAM (p_out, p_attr->len); UINT8_TO_BE_STREAM (p_out, p_attr->len);
} }
}
if (p_attr->value_ptr != NULL) { if (p_attr->value_ptr != NULL) {
ARRAY_TO_BE_STREAM (p_out, p_attr->value_ptr, (int)p_attr->len); ARRAY_TO_BE_STREAM (p_out, p_attr->value_ptr, (int)p_attr->len);
} }
@ -666,10 +667,10 @@ BOOLEAN sdpu_compare_uuid_arrays (UINT8 *p_uuid1, UINT32 len1, UINT8 *p_uuid2, U
if (len1 == 2) { if (len1 == 2) {
return ((p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1])); return ((p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1]));
} }
if (len1 == 4) if (len1 == 4) {
return ( (p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1]) return ( (p_uuid1[0] == p_uuid2[0]) && (p_uuid1[1] == p_uuid2[1])
&& (p_uuid1[2] == p_uuid2[2]) && (p_uuid1[3] == p_uuid2[3]) ); && (p_uuid1[2] == p_uuid2[2]) && (p_uuid1[3] == p_uuid2[3]) );
else { } else {
return (memcmp (p_uuid1, p_uuid2, (size_t)len1) == 0); return (memcmp (p_uuid1, p_uuid2, (size_t)len1) == 0);
} }
} else if (len1 > len2) { } else if (len1 > len2) {
@ -926,6 +927,7 @@ UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr)
} else } else
#endif/* 0xFFFF - 0xFF */ #endif/* 0xFFFF - 0xFF */
{
#if (SDP_MAX_ATTR_LEN > 0xFF) #if (SDP_MAX_ATTR_LEN > 0xFF)
if (p_attr->len > 0xFF) { if (p_attr->len > 0xFF) {
len += 3; len += 3;
@ -935,6 +937,7 @@ UINT16 sdpu_get_attrib_entry_len(tSDP_ATTRIBUTE *p_attr)
{ {
len += 2; len += 2;
} }
}
len += p_attr->len; len += p_attr->len;
return len; return len;
} }

View file

@ -241,25 +241,25 @@ static uint_8t gf_inv(const uint_8t x)
} }
for ( ; ; ) { for ( ; ; ) {
if (n1) if (n1) {
while (n2 >= n1) { /* divide polynomial p2 by p1 */ while (n2 >= n1) { /* divide polynomial p2 by p1 */
n2 /= n1; /* shift smaller polynomial left */ n2 /= n1; /* shift smaller polynomial left */
p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */ p2 ^= (p1 * n2) & 0xff; /* and remove from larger one */
v2 ^= (v1 * n2); /* shift accumulated value and */ v2 ^= (v1 * n2); /* shift accumulated value and */
n2 = hibit(p2); /* add into result */ n2 = hibit(p2); /* add into result */
} }
else { } else {
return v1; return v1;
} }
if (n2) /* repeat with values swapped */ if (n2) { /* repeat with values swapped */
while (n1 >= n2) { while (n1 >= n2) {
n1 /= n2; n1 /= n2;
p1 ^= p2 * n1; p1 ^= p2 * n1;
v1 ^= v2 * n1; v1 ^= v2 * n1;
n1 = hibit(p1); n1 = hibit(p1);
} }
else { } else {
return v2; return v2;
} }
} }

View file

@ -363,9 +363,10 @@ void smp_send_enc_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
le_key.key_size = p_cb->loc_enc_size; le_key.key_size = p_cb->loc_enc_size;
le_key.sec_level = p_cb->sec_level; le_key.sec_level = p_cb->sec_level;
if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) {
btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LENC, btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LENC,
(tBTM_LE_KEY_VALUE *)&le_key, TRUE); (tBTM_LE_KEY_VALUE *)&le_key, TRUE);
}
SMP_TRACE_DEBUG ("%s\n", __func__); SMP_TRACE_DEBUG ("%s\n", __func__);
@ -385,9 +386,10 @@ void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
smp_send_cmd(SMP_OPCODE_IDENTITY_INFO, p_cb); smp_send_cmd(SMP_OPCODE_IDENTITY_INFO, p_cb);
smp_send_cmd(SMP_OPCODE_ID_ADDR, p_cb); smp_send_cmd(SMP_OPCODE_ID_ADDR, p_cb);
if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) {
btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LID, btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_LID,
&le_key, TRUE); &le_key, TRUE);
}
smp_key_distribution_by_transport(p_cb, NULL); smp_key_distribution_by_transport(p_cb, NULL);
} }
@ -526,7 +528,7 @@ uint16_t smp_get_auth_mode (tSMP_ASSO_MODEL model)
auth = 0; auth = 0;
} }
return auth; return auth;
} }
/******************************************************************************* /*******************************************************************************
** Function smp_proc_pair_cmd ** Function smp_proc_pair_cmd
@ -735,7 +737,7 @@ void smp_process_pairing_public_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
STREAM_TO_ARRAY(p_cb->peer_publ_key.x, p, BT_OCTET32_LEN); STREAM_TO_ARRAY(p_cb->peer_publ_key.x, p, BT_OCTET32_LEN);
STREAM_TO_ARRAY(p_cb->peer_publ_key.y, p, BT_OCTET32_LEN); STREAM_TO_ARRAY(p_cb->peer_publ_key.y, p, BT_OCTET32_LEN);
/* In order to prevent the x and y coordinates of the public key from being modified, /* In order to prevent the x and y coordinates of the public key from being modified,
we need to check whether the x and y coordinates are on the given elliptic curve. */ we need to check whether the x and y coordinates are on the given elliptic curve. */
if (!ECC_CheckPointIsInElliCur_P256((Point *)&p_cb->peer_publ_key)) { if (!ECC_CheckPointIsInElliCur_P256((Point *)&p_cb->peer_publ_key)) {
SMP_TRACE_ERROR("%s, Invalid Public key.", __func__); SMP_TRACE_ERROR("%s, Invalid Public key.", __func__);
@ -995,10 +997,11 @@ void smp_proc_master_id(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
le_key.sec_level = p_cb->sec_level; le_key.sec_level = p_cb->sec_level;
le_key.key_size = p_cb->loc_enc_size; le_key.key_size = p_cb->loc_enc_size;
if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) {
btm_sec_save_le_key(p_cb->pairing_bda, btm_sec_save_le_key(p_cb->pairing_bda,
BTM_LE_KEY_PENC, BTM_LE_KEY_PENC,
(tBTM_LE_KEY_VALUE *)&le_key, TRUE); (tBTM_LE_KEY_VALUE *)&le_key, TRUE);
}
smp_key_distribution(p_cb, NULL); smp_key_distribution(p_cb, NULL);
} }
@ -1038,9 +1041,10 @@ void smp_proc_id_addr(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
memcpy(p_cb->id_addr, pid_key.static_addr, BD_ADDR_LEN); memcpy(p_cb->id_addr, pid_key.static_addr, BD_ADDR_LEN);
/* store the ID key from peer device */ /* store the ID key from peer device */
if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) {
btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_PID, btm_sec_save_le_key(p_cb->pairing_bda, BTM_LE_KEY_PID,
(tBTM_LE_KEY_VALUE *)&pid_key, TRUE); (tBTM_LE_KEY_VALUE *)&pid_key, TRUE);
}
smp_key_distribution_by_transport(p_cb, NULL); smp_key_distribution_by_transport(p_cb, NULL);
} }
@ -1060,10 +1064,11 @@ void smp_proc_srk_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
memcpy (le_key.csrk, p_data, BT_OCTET16_LEN); /* get peer CSRK */ memcpy (le_key.csrk, p_data, BT_OCTET16_LEN); /* get peer CSRK */
le_key.counter = 0; /* initialize the peer counter */ le_key.counter = 0; /* initialize the peer counter */
if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) if ((p_cb->peer_auth_req & SMP_AUTH_BOND) && (p_cb->loc_auth_req & SMP_AUTH_BOND)) {
btm_sec_save_le_key(p_cb->pairing_bda, btm_sec_save_le_key(p_cb->pairing_bda,
BTM_LE_KEY_PCSRK, BTM_LE_KEY_PCSRK,
(tBTM_LE_KEY_VALUE *)&le_key, TRUE); (tBTM_LE_KEY_VALUE *)&le_key, TRUE);
}
smp_key_distribution_by_transport(p_cb, NULL); smp_key_distribution_by_transport(p_cb, NULL);
} }
@ -1932,10 +1937,10 @@ void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable)
} }
smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable); smp_sm_event(&smp_cb, SMP_ENCRYPTED_EVT, &encr_enable);
} }
else if(p_dev_rec && !p_dev_rec->enc_init_by_we){ else if(p_dev_rec && !p_dev_rec->enc_init_by_we){
/* /*
if enc_init_by_we is false, it means that client initiates encryption before slave calls esp_ble_set_encryption() if enc_init_by_we is false, it means that client initiates encryption before slave calls esp_ble_set_encryption()
we need initiate pairing_bda and p_cb->role then encryption, for example iPhones we need initiate pairing_bda and p_cb->role then encryption, for example iPhones
*/ */