mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
Merge branch 'bugfix/fix_some_bluedroid_bugs_260121_v5.4' into 'release/v5.4'
Bugfix/fix some bluedroid bugs 260121 (5.4) See merge request espressif/esp-idf!46982
This commit is contained in:
@@ -49,6 +49,7 @@
|
||||
#include "stack/hcidefs.h"
|
||||
//#include "bt_utils.h"
|
||||
#include "osi/list.h"
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
static void btm_read_remote_features (UINT16 handle);
|
||||
static void btm_read_remote_ext_features (UINT16 handle, UINT8 page_number);
|
||||
@@ -362,124 +363,131 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
|
||||
}
|
||||
else {
|
||||
p = (tACL_CONN *)osi_malloc(sizeof(tACL_CONN));
|
||||
if (p && list_append(btm_cb.p_acl_db_list, p)) {
|
||||
memset(p, 0, sizeof(tACL_CONN));
|
||||
p->in_use = TRUE;
|
||||
p->hci_handle = hci_handle;
|
||||
p->link_role = link_role;
|
||||
p->link_up_issued = FALSE;
|
||||
memcpy (p->remote_addr, bda, BD_ADDR_LEN);
|
||||
/* Set the default version of the peer device to version4.0 before exchange the version with it.
|
||||
If the peer device act as a master and don't exchange the version with us, then it can only use the
|
||||
legacy connect instead of secure connection in the pairing step. */
|
||||
p->lmp_version = HCI_PROTO_VERSION_4_0;
|
||||
if (p == NULL) {
|
||||
BTM_TRACE_ERROR("btm_acl_created: osi_malloc failed for tACL_CONN\n");
|
||||
return;
|
||||
}
|
||||
if (!list_append(btm_cb.p_acl_db_list, p)) {
|
||||
BTM_TRACE_ERROR("btm_acl_created: list_append failed\n");
|
||||
osi_free(p);
|
||||
return;
|
||||
}
|
||||
memset(p, 0, sizeof(tACL_CONN));
|
||||
p->in_use = TRUE;
|
||||
p->hci_handle = hci_handle;
|
||||
p->link_role = link_role;
|
||||
p->link_up_issued = FALSE;
|
||||
memcpy (p->remote_addr, bda, BD_ADDR_LEN);
|
||||
/* Set the default version of the peer device to version4.0 before exchange the version with it.
|
||||
If the peer device act as a master and don't exchange the version with us, then it can only use the
|
||||
legacy connect instead of secure connection in the pairing step. */
|
||||
p->lmp_version = HCI_PROTO_VERSION_4_0;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
p->transport = transport;
|
||||
p->transport = transport;
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
btm_ble_refresh_local_resolvable_private_addr(bda,
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
|
||||
}
|
||||
if (transport == BT_TRANSPORT_LE) {
|
||||
btm_ble_refresh_local_resolvable_private_addr(bda,
|
||||
btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr);
|
||||
}
|
||||
#else
|
||||
p->conn_addr_type = BLE_ADDR_PUBLIC;
|
||||
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||
BTM_TRACE_DEBUG ("conn_addr: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]);
|
||||
p->conn_addr_type = BLE_ADDR_PUBLIC;
|
||||
memcpy(p->conn_addr, &controller_get_interface()->get_address()->address, BD_ADDR_LEN);
|
||||
BTM_TRACE_DEBUG ("conn_addr: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
p->conn_addr[0], p->conn_addr[1], p->conn_addr[2], p->conn_addr[3], p->conn_addr[4], p->conn_addr[5]);
|
||||
#endif
|
||||
#endif
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
|
||||
p->switch_role_state = BTM_ACL_SWKEY_STATE_IDLE;
|
||||
|
||||
|
||||
p->p_pm_mode_db = btm_pm_sm_alloc();
|
||||
p->p_pm_mode_db = btm_pm_sm_alloc();
|
||||
|
||||
#if BTM_PM_DEBUG == TRUE
|
||||
BTM_TRACE_DEBUG( "btm_pm_sm_alloc handle:%d st:%d", hci_handle, p->p_pm_mode_db->state);
|
||||
BTM_TRACE_DEBUG( "btm_pm_sm_alloc handle:%d st:%d", hci_handle, p->p_pm_mode_db->state);
|
||||
#endif // BTM_PM_DEBUG
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
btm_sec_update_legacy_auth_state(p, BTM_ACL_LEGACY_AUTH_NONE);
|
||||
btm_sec_update_legacy_auth_state(p, BTM_ACL_LEGACY_AUTH_NONE);
|
||||
#endif
|
||||
|
||||
if (dc) {
|
||||
memcpy (p->remote_dc, dc, DEV_CLASS_LEN);
|
||||
}
|
||||
if (dc) {
|
||||
memcpy (p->remote_dc, dc, DEV_CLASS_LEN);
|
||||
}
|
||||
|
||||
if (bdn) {
|
||||
memcpy (p->remote_name, bdn, BTM_MAX_REM_BD_NAME_LEN);
|
||||
}
|
||||
if (bdn) {
|
||||
memcpy (p->remote_name, bdn, BTM_MAX_REM_BD_NAME_LEN);
|
||||
}
|
||||
|
||||
/* if BR/EDR do something more */
|
||||
if (transport == BT_TRANSPORT_BR_EDR) {
|
||||
btsnd_hcic_read_rmt_clk_offset (p->hci_handle);
|
||||
btsnd_hcic_rmt_ver_req (p->hci_handle);
|
||||
}
|
||||
p_dev_rec = btm_find_dev_by_handle (hci_handle);
|
||||
/* if BR/EDR do something more */
|
||||
if (transport == BT_TRANSPORT_BR_EDR) {
|
||||
btsnd_hcic_read_rmt_clk_offset (p->hci_handle);
|
||||
btsnd_hcic_rmt_ver_req (p->hci_handle);
|
||||
}
|
||||
p_dev_rec = btm_find_dev_by_handle (hci_handle);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if (p_dev_rec ) {
|
||||
BTM_TRACE_DEBUG ("device_type=0x%x\n", p_dev_rec->device_type);
|
||||
}
|
||||
if (p_dev_rec ) {
|
||||
BTM_TRACE_DEBUG ("device_type=0x%x\n", p_dev_rec->device_type);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_dev_rec && !(transport == BT_TRANSPORT_LE)) {
|
||||
if (!p_dev_rec->remote_secure_connection_previous_state) {
|
||||
/* If remote features already known, copy them and continue connection setup */
|
||||
if ((p_dev_rec->num_read_pages) &&
|
||||
(p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) {
|
||||
memcpy (p->peer_lmp_features, p_dev_rec->features,
|
||||
(HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages));
|
||||
p->num_read_pages = p_dev_rec->num_read_pages;
|
||||
if (p_dev_rec && !(transport == BT_TRANSPORT_LE)) {
|
||||
if (!p_dev_rec->remote_secure_connection_previous_state) {
|
||||
/* If remote features already known, copy them and continue connection setup */
|
||||
if ((p_dev_rec->num_read_pages) &&
|
||||
(p_dev_rec->num_read_pages <= (HCI_EXT_FEATURES_PAGE_MAX + 1))) {
|
||||
memcpy (p->peer_lmp_features, p_dev_rec->features,
|
||||
(HCI_FEATURE_BYTES_PER_PAGE * p_dev_rec->num_read_pages));
|
||||
p->num_read_pages = p_dev_rec->num_read_pages;
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
|
||||
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
|
||||
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btm_sec_set_peer_sec_caps(p, p_dev_rec);
|
||||
btm_sec_set_peer_sec_caps(p, p_dev_rec);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
|
||||
if (req_pend) {
|
||||
/* Request for remaining Security Features (if any) */
|
||||
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
|
||||
}
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
btm_establish_continue (p);
|
||||
return;
|
||||
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
|
||||
if (req_pend) {
|
||||
/* Request for remaining Security Features (if any) */
|
||||
l2cu_resubmit_pending_sec_req (p_dev_rec->bd_addr);
|
||||
}
|
||||
} else {
|
||||
/* If remote features indicated secure connection (SC) mode, check the remote features again*/
|
||||
/* this is to prevent from BIAS attack where attacker can downgrade SC mode*/
|
||||
btm_read_remote_features (p->hci_handle);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
btm_establish_continue (p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/* If here, features are not known yet */
|
||||
if (p_dev_rec && transport == BT_TRANSPORT_LE) {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
btm_ble_get_acl_remote_addr (p_dev_rec, p->active_remote_addr,
|
||||
&p->active_remote_addr_type);
|
||||
#endif
|
||||
|
||||
if (link_role == HCI_ROLE_MASTER) {
|
||||
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
|
||||
} else if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)
|
||||
&& link_role == HCI_ROLE_SLAVE) {
|
||||
btsnd_hcic_rmt_ver_req (p->hci_handle);
|
||||
} else {
|
||||
btm_establish_continue(p);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
} else {
|
||||
/* If remote features indicated secure connection (SC) mode, check the remote features again*/
|
||||
/* this is to prevent from BIAS attack where attacker can downgrade SC mode*/
|
||||
btm_read_remote_features (p->hci_handle);
|
||||
}
|
||||
|
||||
/* read page 1 - on rmt feature event for buffer reasons */
|
||||
return;
|
||||
}
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
/* If here, features are not known yet */
|
||||
if (p_dev_rec && transport == BT_TRANSPORT_LE) {
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
btm_ble_get_acl_remote_addr (p_dev_rec, p->active_remote_addr,
|
||||
&p->active_remote_addr_type);
|
||||
#endif
|
||||
|
||||
if (link_role == HCI_ROLE_MASTER) {
|
||||
btsnd_hcic_ble_read_remote_feat(p->hci_handle);
|
||||
} else if (HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(controller_get_interface()->get_features_ble()->as_array)
|
||||
&& link_role == HCI_ROLE_SLAVE) {
|
||||
btsnd_hcic_rmt_ver_req (p->hci_handle);
|
||||
} else {
|
||||
btm_establish_continue(p);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
btm_read_remote_features (p->hci_handle);
|
||||
}
|
||||
|
||||
/* read page 1 - on rmt feature event for buffer reasons */
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -589,11 +597,9 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
list_remove(btm_cb.p_pm_mode_db_list, p->p_pm_mode_db);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
/* Clear the ACL connection data */
|
||||
memset(p, 0, sizeof(tACL_CONN));
|
||||
if (list_remove(btm_cb.p_acl_db_list, p)) {
|
||||
p = NULL;
|
||||
}
|
||||
/* Remove and free the ACL connection data */
|
||||
list_remove(btm_cb.p_acl_db_list, p);
|
||||
p = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2270,10 +2276,12 @@ void btm_acl_pkt_types_changed(UINT8 status, UINT16 handle, UINT16 pkt_types)
|
||||
** Returns BTM_CMD_STARTED if successfully initiated or error code
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
|
||||
tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda)
|
||||
{
|
||||
tACL_CONN *p;
|
||||
tBTM_BLE_CH_MAP_RESULTS result;
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params;
|
||||
UINT8 status;
|
||||
|
||||
BTM_TRACE_DEBUG("BTM_ReadChannelMap: RemBdAddr: %02x%02x%02x%02x%02x%02x\n",
|
||||
remote_bda[0], remote_bda[1], remote_bda[2],
|
||||
@@ -2281,29 +2289,33 @@ tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb)
|
||||
|
||||
memset(result.channel_map, 0, sizeof(result.channel_map)); // Clear channel map data
|
||||
/* If someone already waiting for the channel map, do not allow another */
|
||||
if (btm_cb.devcb.p_ble_ch_map_cmpl_cb) {
|
||||
if (btm_cb.devcb.is_ch_map_cb) {
|
||||
result.status = BTM_BUSY;
|
||||
(*p_cb)(&result);
|
||||
return BTM_BUSY;
|
||||
status = BTM_BUSY;
|
||||
goto _ch_map_err;
|
||||
}
|
||||
p = btm_bda_to_acl(remote_bda, BT_TRANSPORT_LE);
|
||||
if (p != NULL) {
|
||||
btm_cb.devcb.p_ble_ch_map_cmpl_cb = p_cb;
|
||||
|
||||
if (!btsnd_hcic_ble_read_chnl_map(p->hci_handle)) {
|
||||
btm_cb.devcb.p_ble_ch_map_cmpl_cb = NULL;
|
||||
btm_cb.devcb.is_ch_map_cb = false;
|
||||
result.status = BTM_NO_RESOURCES;
|
||||
(*p_cb)(&result);
|
||||
return BTM_NO_RESOURCES;
|
||||
status = BTM_NO_RESOURCES;
|
||||
goto _ch_map_err;
|
||||
} else {
|
||||
btm_cb.devcb.is_ch_map_cb = true;
|
||||
return BTM_CMD_STARTED;
|
||||
}
|
||||
}
|
||||
|
||||
status = BTM_UNKNOWN_ADDR;
|
||||
/* If here, no BD Addr found */
|
||||
result.status = BTM_UNKNOWN_ADDR;
|
||||
(*p_cb)(&result);
|
||||
return BTM_UNKNOWN_ADDR;
|
||||
|
||||
_ch_map_err:
|
||||
memset(&cb_params, 0, sizeof(cb_params));
|
||||
// `ch_map_read` is same as `results`
|
||||
memcpy(&cb_params.ch_map_results, &result, sizeof(tBTM_BLE_CH_MAP_RESULTS));
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_READ_CHANNEL_MAP_EVT, &cb_params);
|
||||
return status;
|
||||
}
|
||||
|
||||
void BTM_BleGetWhiteListSize(uint16_t *length)
|
||||
@@ -2344,17 +2356,16 @@ void BTM_BleGetPeriodicAdvListSize(uint8_t *size)
|
||||
*******************************************************************************/
|
||||
void btm_read_channel_map_complete(UINT8 *p)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_ble_ch_map_cmpl_cb;
|
||||
tBTM_BLE_CH_MAP_RESULTS results;
|
||||
UINT16 handle;
|
||||
tACL_CONN *p_acl_cb = NULL;
|
||||
|
||||
BTM_TRACE_DEBUG("btm_read_channel_map_complete\n");
|
||||
|
||||
/* Reset the callback pointer to prevent duplicate calls */
|
||||
btm_cb.devcb.p_ble_ch_map_cmpl_cb = NULL;
|
||||
|
||||
if (p_cb) {
|
||||
if (btm_cb.devcb.is_ch_map_cb) {
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params;
|
||||
/* Reset the callback pointer to prevent duplicate calls */
|
||||
btm_cb.devcb.is_ch_map_cb = false;
|
||||
/* Extract HCI status from the response */
|
||||
STREAM_TO_UINT8(results.hci_status, p);
|
||||
|
||||
@@ -2381,7 +2392,10 @@ void btm_read_channel_map_complete(UINT8 *p)
|
||||
}
|
||||
|
||||
/* Invoke the registered callback with the results */
|
||||
(*p_cb)(&results);
|
||||
memset(&cb_params, 0, sizeof(cb_params));
|
||||
// `ch_map_read` is same as `results`
|
||||
memcpy(&cb_params.ch_map_results, &results, sizeof(tBTM_BLE_CH_MAP_RESULTS));
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_READ_CHANNEL_MAP_EVT, &cb_params);
|
||||
}
|
||||
}
|
||||
#endif // #if BLE_INCLUDED == TRUE
|
||||
@@ -2399,7 +2413,7 @@ void btm_read_channel_map_complete(UINT8 *p)
|
||||
void btm_read_rssi_complete (UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_rssi_cmpl_cb;
|
||||
tBTM_RSSI_RESULTS results;
|
||||
tBTM_RSSI_RESULTS results = {0};
|
||||
UINT16 handle;
|
||||
tACL_CONN *p_acl_cb = NULL;
|
||||
BTM_TRACE_DEBUG ("btm_read_rssi_complete\n");
|
||||
@@ -2431,10 +2445,12 @@ void btm_read_rssi_complete (UINT8 *p, UINT16 evt_len)
|
||||
results.rssi, results.hci_status);
|
||||
|
||||
/* Search through the list of active channels for the correct BD Addr */
|
||||
p_acl_cb = btm_handle_to_acl(handle);
|
||||
if (p_acl_cb) {
|
||||
p_acl_cb = btm_handle_to_acl(handle);
|
||||
if (p_acl_cb) {
|
||||
memcpy (results.rem_bda, p_acl_cb->remote_addr, BD_ADDR_LEN);
|
||||
}
|
||||
} else {
|
||||
results.status = BTM_UNKNOWN_ADDR;
|
||||
}
|
||||
} else {
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
}
|
||||
|
||||
@@ -407,8 +407,9 @@ void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey)
|
||||
BTM_TRACE_ERROR("Passkey reply to Unknown device");
|
||||
return;
|
||||
}
|
||||
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
|
||||
if (res_smp == SMP_SUCCESS) {
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
|
||||
}
|
||||
BTM_TRACE_DEBUG ("BTM_BlePasskeyReply");
|
||||
SMP_PasskeyReply(bd_addr, res_smp, passkey);
|
||||
#endif
|
||||
@@ -487,8 +488,9 @@ void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data)
|
||||
BTM_TRACE_ERROR("BTM_BleOobDataReply() to Unknown device");
|
||||
return;
|
||||
}
|
||||
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
|
||||
if (res_smp == SMP_SUCCESS) {
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
|
||||
}
|
||||
SMP_OobDataReply(bd_addr, res_smp, len, p_data);
|
||||
#endif
|
||||
}
|
||||
@@ -902,7 +904,7 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length)
|
||||
} else if (tx_pdu_length < BTM_BLE_DATA_SIZE_MIN) {
|
||||
tx_pdu_length = BTM_BLE_DATA_SIZE_MIN;
|
||||
}
|
||||
|
||||
p_acl->data_len_updating = true;
|
||||
/* always set the TxTime to be max, as controller does not care for now */
|
||||
btsnd_hcic_ble_set_data_length(p_acl->hci_handle, tx_pdu_length,
|
||||
BTM_BLE_DATA_TX_TIME_MAX);
|
||||
@@ -1431,6 +1433,7 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE
|
||||
|
||||
if (p_dev_rec == NULL) {
|
||||
BTM_TRACE_ERROR ("btm_ble_link_sec_check received for unknown device");
|
||||
*p_sec_req_act = BTM_BLE_SEC_REQ_ACT_NONE;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2170,9 +2173,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
|
||||
case SMP_OOB_REQ_EVT:
|
||||
case SMP_NC_REQ_EVT:
|
||||
case SMP_SC_OOB_REQ_EVT:
|
||||
/* fall through */
|
||||
p_dev_rec->sec_flags |= BTM_SEC_LE_AUTHENTICATED;
|
||||
|
||||
/* fall through */
|
||||
case SMP_SEC_REQUEST_EVT:
|
||||
if (event == SMP_SEC_REQUEST_EVT && btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) {
|
||||
BTM_TRACE_DEBUG("%s: Ignoring SMP Security request", __func__);
|
||||
|
||||
@@ -16,12 +16,14 @@ tBTM_BLE_EXTENDED_CB extend_adv_cb;
|
||||
|
||||
tBTM_BLE_5_HCI_CBACK ble_5_hci_cb;
|
||||
|
||||
#define INVALID_VALUE 0XFF
|
||||
#define INVALID_VALUE_8BIT 0XFF
|
||||
#define INVALID_VALUE_16BIT 0XFFFF
|
||||
#define INVALID_VALUE_32BIT 0XFFFFFFFF
|
||||
|
||||
extern BOOLEAN BTM_GetLocalResolvablePrivateAddr(BD_ADDR bda);
|
||||
extern void BTM_UpdateAddrInfor(uint8_t addr_type, BD_ADDR bda);
|
||||
extern void BTM_BleSetStaticAddr(BD_ADDR rand_addr);
|
||||
extern uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type, tBTM_START_ADV_CMPL_CBACK *cb);
|
||||
extern uint32_t BTM_BleUpdateOwnType(uint8_t *own_bda_type);
|
||||
#if (BLE_50_EXTEND_ADV_EN == TRUE)
|
||||
static tBTM_STATUS btm_ble_ext_adv_params_validate(tBTM_BLE_GAP_EXT_ADV_PARAMS *params);
|
||||
static tBTM_STATUS btm_ble_ext_adv_set_data_validate(UINT8 instance, UINT16 len, UINT8 *data);
|
||||
@@ -54,158 +56,6 @@ static tBTM_BLE_SYNC_RETRY_CB sync_retry_cb = {0};
|
||||
|
||||
extern void btm_ble_inter_set(bool extble_inter);
|
||||
|
||||
#if !UC_BT_STACK_NO_LOG
|
||||
static const char *btm_ble_hci_status_to_str(tHCI_STATUS status)
|
||||
{
|
||||
switch(status) {
|
||||
case HCI_SUCCESS:
|
||||
return "HCI_SUCCESS";
|
||||
case HCI_ERR_ILLEGAL_COMMAND:
|
||||
return "HCI_ERR_ILLEGAL_COMMAND";
|
||||
case HCI_ERR_NO_CONNECTION:
|
||||
return "HCI_ERR_NO_CONNECTION";
|
||||
case HCI_ERR_HW_FAILURE:
|
||||
return "HCI_ERR_HW_FAILURE";
|
||||
case HCI_ERR_PAGE_TIMEOUT:
|
||||
return "HCI_ERR_PAGE_TIMEOUT";
|
||||
case HCI_ERR_AUTH_FAILURE:
|
||||
return "HCI_ERR_AUTH_FAILURE";
|
||||
case HCI_ERR_KEY_MISSING:
|
||||
return "HCI_ERR_KEY_MISSING";
|
||||
case HCI_ERR_MEMORY_FULL:
|
||||
return "HCI_ERR_MEMORY_FULL";
|
||||
case HCI_ERR_CONNECTION_TOUT:
|
||||
return "HCI_ERR_CONNECTION_TOUT";
|
||||
case HCI_ERR_MAX_NUM_OF_CONNECTIONS:
|
||||
return "HCI_ERR_MAX_NUM_OF_CONNECTIONS";
|
||||
case HCI_ERR_MAX_NUM_OF_SCOS:
|
||||
return "HCI_ERR_MAX_NUM_OF_SCOS";
|
||||
case HCI_ERR_CONNECTION_EXISTS:
|
||||
return "HCI_ERR_CONNECTION_EXISTS";
|
||||
case HCI_ERR_COMMAND_DISALLOWED:
|
||||
return "HCI_ERR_COMMAND_DISALLOWED";
|
||||
case HCI_ERR_HOST_REJECT_RESOURCES:
|
||||
return "HCI_ERR_HOST_REJECT_RESOURCES";
|
||||
case HCI_ERR_HOST_REJECT_SECURITY:
|
||||
return "HCI_ERR_HOST_REJECT_SECURITY";
|
||||
case HCI_ERR_HOST_REJECT_DEVICE:
|
||||
return "HCI_ERR_HOST_REJECT_DEVICE";
|
||||
case HCI_ERR_HOST_TIMEOUT:
|
||||
return "HCI_ERR_HOST_TIMEOUT";
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
return "HCI_ERR_UNSUPPORTED_VALUE";
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
return "HCI_ERR_ILLEGAL_PARAMETER_FMT";
|
||||
case HCI_ERR_PEER_USER:
|
||||
return "HCI_ERR_PEER_USER";
|
||||
case HCI_ERR_PEER_LOW_RESOURCES:
|
||||
return "HCI_ERR_PEER_LOW_RESOURCES";
|
||||
case HCI_ERR_PEER_POWER_OFF:
|
||||
return "HCI_ERR_PEER_POWER_OFF";
|
||||
case HCI_ERR_CONN_CAUSE_LOCAL_HOST:
|
||||
return "HCI_ERR_CONN_CAUSE_LOCAL_HOST";
|
||||
case HCI_ERR_REPEATED_ATTEMPTS:
|
||||
return "HCI_ERR_REPEATED_ATTEMPTS";
|
||||
case HCI_ERR_PAIRING_NOT_ALLOWED:
|
||||
return "HCI_ERR_PAIRING_NOT_ALLOWED";
|
||||
case HCI_ERR_UNKNOWN_LMP_PDU:
|
||||
return "HCI_ERR_UNKNOWN_LMP_PDU";
|
||||
case HCI_ERR_UNSUPPORTED_REM_FEATURE:
|
||||
return "HCI_ERR_UNSUPPORTED_REM_FEATURE";
|
||||
case HCI_ERR_SCO_OFFSET_REJECTED:
|
||||
return "HCI_ERR_SCO_OFFSET_REJECTED";
|
||||
case HCI_ERR_SCO_INTERVAL_REJECTED:
|
||||
return "HCI_ERR_SCO_INTERVAL_REJECTED";
|
||||
case HCI_ERR_SCO_AIR_MODE:
|
||||
return "HCI_ERR_SCO_AIR_MODE";
|
||||
case HCI_ERR_INVALID_LMP_PARAM:
|
||||
return "HCI_ERR_INVALID_LMP_PARAM";
|
||||
case HCI_ERR_UNSPECIFIED:
|
||||
return "HCI_ERR_UNSPECIFIED";
|
||||
case HCI_ERR_UNSUPPORTED_LMP_PARAMETERS:
|
||||
return "HCI_ERR_UNSUPPORTED_LMP_PARAMETERS";
|
||||
case HCI_ERR_ROLE_CHANGE_NOT_ALLOWED:
|
||||
return "HCI_ERR_ROLE_CHANGE_NOT_ALLOWED";
|
||||
case HCI_ERR_LMP_RESPONSE_TIMEOUT:
|
||||
return "HCI_ERR_LMP_RESPONSE_TIMEOUT";
|
||||
case HCI_ERR_LMP_ERR_TRANS_COLLISION:
|
||||
return "HCI_ERR_LMP_ERR_TRANS_COLLISION";
|
||||
case HCI_ERR_LMP_PDU_NOT_ALLOWED:
|
||||
return "HCI_ERR_LMP_PDU_NOT_ALLOWED";
|
||||
case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
|
||||
return "HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE";
|
||||
case HCI_ERR_UNIT_KEY_USED:
|
||||
return "HCI_ERR_UNIT_KEY_USED";
|
||||
case HCI_ERR_QOS_NOT_SUPPORTED:
|
||||
return "HCI_ERR_QOS_NOT_SUPPORTED";
|
||||
case HCI_ERR_INSTANT_PASSED:
|
||||
return "HCI_ERR_INSTANT_PASSED";
|
||||
case HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED:
|
||||
return "HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED";
|
||||
case HCI_ERR_DIFF_TRANSACTION_COLLISION:
|
||||
return "HCI_ERR_DIFF_TRANSACTION_COLLISION";
|
||||
case HCI_ERR_UNDEFINED_0x2B:
|
||||
return "HCI_ERR_UNDEFINED_0x2B";
|
||||
case HCI_ERR_QOS_UNACCEPTABLE_PARAM:
|
||||
return "HCI_ERR_QOS_UNACCEPTABLE_PARAM";
|
||||
case HCI_ERR_QOS_REJECTED:
|
||||
return "HCI_ERR_QOS_REJECTED";
|
||||
case HCI_ERR_CHAN_CLASSIF_NOT_SUPPORTED:
|
||||
return "HCI_ERR_CHAN_CLASSIF_NOT_SUPPORTED";
|
||||
case HCI_ERR_INSUFFCIENT_SECURITY:
|
||||
return "HCI_ERR_INSUFFCIENT_SECURITY";
|
||||
case HCI_ERR_PARAM_OUT_OF_RANGE:
|
||||
return "HCI_ERR_PARAM_OUT_OF_RANGE";
|
||||
case HCI_ERR_UNDEFINED_0x31:
|
||||
return "HCI_ERR_UNDEFINED_0x31";
|
||||
case HCI_ERR_ROLE_SWITCH_PENDING:
|
||||
return "HCI_ERR_ROLE_SWITCH_PENDING";
|
||||
case HCI_ERR_UNDEFINED_0x33:
|
||||
return "HCI_ERR_UNDEFINED_0x33";
|
||||
case HCI_ERR_RESERVED_SLOT_VIOLATION:
|
||||
return "HCI_ERR_RESERVED_SLOT_VIOLATION";
|
||||
case HCI_ERR_ROLE_SWITCH_FAILED:
|
||||
return "HCI_ERR_ROLE_SWITCH_FAILED";
|
||||
case HCI_ERR_INQ_RSP_DATA_TOO_LARGE:
|
||||
return "HCI_ERR_INQ_RSP_DATA_TOO_LARGE";
|
||||
case HCI_ERR_SIMPLE_PAIRING_NOT_SUPPORTED:
|
||||
return "HCI_ERR_SIMPLE_PAIRING_NOT_SUPPORTED";
|
||||
case HCI_ERR_HOST_BUSY_PAIRING:
|
||||
return "HCI_ERR_HOST_BUSY_PAIRING";
|
||||
case HCI_ERR_REJ_NO_SUITABLE_CHANNEL:
|
||||
return "HCI_ERR_REJ_NO_SUITABLE_CHANNEL";
|
||||
case HCI_ERR_CONTROLLER_BUSY:
|
||||
return "HCI_ERR_CONTROLLER_BUSY";
|
||||
case HCI_ERR_UNACCEPT_CONN_INTERVAL:
|
||||
return "HCI_ERR_UNACCEPT_CONN_INTERVAL";
|
||||
case HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT:
|
||||
return "HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT";
|
||||
case HCI_ERR_CONN_TOUT_DUE_TO_MIC_FAILURE:
|
||||
return "HCI_ERR_CONN_TOUT_DUE_TO_MIC_FAILURE";
|
||||
case HCI_ERR_CONN_FAILED_ESTABLISHMENT:
|
||||
return "HCI_ERR_CONN_FAILED_ESTABLISHMENT";
|
||||
case HCI_ERR_MAC_CONNECTION_FAILED:
|
||||
return "HCI_ERR_MAC_CONNECTION_FAILED";
|
||||
case HCI_ERR_LT_ADDR_ALREADY_IN_USE:
|
||||
return "HCI_ERR_LT_ADDR_ALREADY_IN_USE";
|
||||
case HCI_ERR_LT_ADDR_NOT_ALLOCATED:
|
||||
return "HCI_ERR_LT_ADDR_NOT_ALLOCATED";
|
||||
case HCI_ERR_CLB_NOT_ENABLED:
|
||||
return "HCI_ERR_CLB_NOT_ENABLED";
|
||||
case HCI_ERR_MAX_ERR:
|
||||
return "HCI_ERR_MAX_ERR";
|
||||
case HCI_ERR_ESP_VENDOR_FAIL:
|
||||
return "HCI_ERR_ESP_VENDOR_FAIL";
|
||||
case HCI_HINT_TO_RECREATE_AMP_PHYS_LINK:
|
||||
return "HCI_HINT_TO_RECREATE_AMP_PHYS_LINK";
|
||||
default:
|
||||
return "Invalid HCI status code.";
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif /* !UC_BT_STACK_NO_LOG */
|
||||
|
||||
void btm_ble_extendadvcb_init(void)
|
||||
{
|
||||
memset(&extend_adv_cb, 0, sizeof(tBTM_BLE_EXTENDED_CB));
|
||||
@@ -245,9 +95,7 @@ tBTM_STATUS BTM_BleReadPhy(BD_ADDR bd_addr, UINT8 *tx_phy, UINT8 *rx_phy)
|
||||
cb_params.read_phy.status = BTM_ILLEGAL_VALUE;
|
||||
memcpy(cb_params.read_phy.addr, bd_addr, BD_ADDR_LEN);
|
||||
|
||||
if (ble_5_hci_cb) {
|
||||
ble_5_hci_cb(BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT, &cb_params);
|
||||
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
@@ -265,8 +113,8 @@ tBTM_STATUS BTM_BleSetPreferDefaultPhy(UINT8 tx_phy_mask, UINT8 rx_phy_mask)
|
||||
tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0};
|
||||
|
||||
if ((err = btsnd_hcic_ble_set_prefered_default_phy(all_phys, tx_phy_mask, rx_phy_mask)) != HCI_SUCCESS) {
|
||||
BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = %s(0x%x)",
|
||||
__func__, btm_ble_hci_status_to_str(err), err);
|
||||
BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = 0x%x",
|
||||
__func__, err);
|
||||
status = BTM_HCI_ERROR | err;
|
||||
}
|
||||
|
||||
@@ -286,9 +134,7 @@ tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_ma
|
||||
|
||||
if (!p_lcb) {
|
||||
cb_params.status = BTM_ILLEGAL_VALUE;
|
||||
if (ble_5_hci_cb) {
|
||||
ble_5_hci_cb(BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT, &cb_params);
|
||||
BTM_TRACE_ERROR("%s, invalid parameters", __func__);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
@@ -347,8 +193,8 @@ tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr)
|
||||
|
||||
// set random address
|
||||
if((err = btsnd_hcic_ble_set_extend_rand_address(instance, rand_addr)) != HCI_SUCCESS) {
|
||||
BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = %s(0x%x)",
|
||||
__func__, btm_ble_hci_status_to_str(err), err);
|
||||
BTM_TRACE_ERROR("%s, fail to send the hci command, the error code = 0x%x",
|
||||
__func__, err);
|
||||
status = BTM_HCI_ERROR | err;
|
||||
} else {
|
||||
// set random address success, update address info
|
||||
@@ -382,6 +228,7 @@ tBTM_STATUS BTM_BleSetExtendedAdvParams(UINT8 instance, tBTM_BLE_GAP_EXT_ADV_PAR
|
||||
|
||||
if ((status = btm_ble_ext_adv_params_validate(params)) != BTM_SUCCESS) {
|
||||
BTM_TRACE_ERROR("%s, invalid extend adv params.", __func__);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (params->type & BTM_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE) {
|
||||
@@ -529,13 +376,21 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_
|
||||
UINT8 *max_events = NULL;
|
||||
|
||||
// when enable = true, ext_adv = NULL or num = 0, goto end
|
||||
if ((!ext_adv || num == 0) && enable) {
|
||||
if (num > MAX_BLE_ADV_INSTANCE || (num > 0 && !ext_adv) || (enable && num == 0)) {
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
BTM_TRACE_ERROR("%s invalid parameters", __func__);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (num != 0 && ext_adv != NULL) {
|
||||
for (int i = 0; i < num; i++) {
|
||||
if (ext_adv[i].instance >= MAX_BLE_ADV_INSTANCE) {
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
BTM_TRACE_ERROR("%s instance ID %d out of range", __func__, ext_adv[i].instance);
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
instance = osi_malloc(num);
|
||||
duration = osi_malloc(num*sizeof(UINT16));
|
||||
max_events = osi_malloc(num*sizeof(UINT8));
|
||||
@@ -557,10 +412,6 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_
|
||||
BTM_TRACE_ERROR("LE EA En=%d: cmd err=0x%x", enable, err);
|
||||
status = BTM_HCI_ERROR | err;
|
||||
}
|
||||
|
||||
osi_free(instance);
|
||||
osi_free(duration);
|
||||
osi_free(max_events);
|
||||
} else {
|
||||
// enable = false, num == 0 or ext_adv = NULL
|
||||
|
||||
@@ -574,6 +425,15 @@ tBTM_STATUS BTM_BleStartExtAdv(BOOLEAN enable, UINT8 num, tBTM_BLE_EXT_ADV *ext_
|
||||
|
||||
|
||||
end:
|
||||
if (instance) {
|
||||
osi_free(instance);
|
||||
}
|
||||
if (duration) {
|
||||
osi_free(duration);
|
||||
}
|
||||
if (max_events) {
|
||||
osi_free(max_events);
|
||||
}
|
||||
|
||||
if (!enable && status == BTM_SUCCESS) {
|
||||
// disable all ext adv
|
||||
@@ -583,20 +443,23 @@ end:
|
||||
{
|
||||
adv_record[i].invalid = false;
|
||||
adv_record[i].enabled = false;
|
||||
adv_record[i].instance = INVALID_VALUE;
|
||||
adv_record[i].duration = INVALID_VALUE;
|
||||
adv_record[i].max_events = INVALID_VALUE;
|
||||
adv_record[i].instance = INVALID_VALUE_8BIT;
|
||||
adv_record[i].duration = INVALID_VALUE_32BIT;
|
||||
adv_record[i].max_events = INVALID_VALUE_32BIT;
|
||||
adv_record[i].retry_count = 0;
|
||||
}
|
||||
} else {
|
||||
for (uint8_t i = 0; i < num; i++)
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
if (index >= MAX_BLE_ADV_INSTANCE) {
|
||||
continue;
|
||||
}
|
||||
adv_record[index].invalid = false;
|
||||
adv_record[index].enabled = false;
|
||||
adv_record[index].instance = INVALID_VALUE;
|
||||
adv_record[index].duration = INVALID_VALUE;
|
||||
adv_record[index].max_events = INVALID_VALUE;
|
||||
adv_record[index].instance = INVALID_VALUE_8BIT;
|
||||
adv_record[index].duration = INVALID_VALUE_32BIT;
|
||||
adv_record[index].max_events = INVALID_VALUE_32BIT;
|
||||
adv_record[index].retry_count = 0;
|
||||
}
|
||||
}
|
||||
@@ -606,6 +469,9 @@ end:
|
||||
for (uint8_t i = 0; i < num; i++)
|
||||
{
|
||||
uint8_t index = ext_adv[i].instance;
|
||||
if (index >= MAX_BLE_ADV_INSTANCE) {
|
||||
continue;
|
||||
}
|
||||
adv_record[index].invalid = true;
|
||||
adv_record[index].enabled = true;
|
||||
adv_record[index].instance = ext_adv[i].instance;
|
||||
@@ -616,9 +482,12 @@ end:
|
||||
}
|
||||
|
||||
cb_params.adv_start.status = status;
|
||||
num = (num > MAX_BLE_ADV_INSTANCE) ? MAX_BLE_ADV_INSTANCE : num;
|
||||
cb_params.adv_start.instance_num = num;
|
||||
for (uint8_t i = 0; i < num; i++) {
|
||||
cb_params.adv_start.instance[i] = ext_adv[i].instance;
|
||||
if (ext_adv) {
|
||||
for (uint8_t i = 0; i < num; i++) {
|
||||
cb_params.adv_start.instance[i] = ext_adv[i].instance;
|
||||
}
|
||||
}
|
||||
|
||||
BTM_ExtBleCallbackTrigger(enable ? BTM_BLE_5_GAP_EXT_ADV_START_COMPLETE_EVT : BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT, &cb_params);
|
||||
@@ -626,10 +495,10 @@ end:
|
||||
return status;
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t con_handle)
|
||||
tBTM_STATUS BTM_BleStartExtAdvRestart(uint16_t con_handle)
|
||||
{
|
||||
tBTM_BLE_EXT_ADV ext_adv;
|
||||
uint8_t index = INVALID_VALUE;
|
||||
uint8_t index = INVALID_VALUE_8BIT;
|
||||
for (uint8_t i = 0; i < MAX_BLE_ADV_INSTANCE; i++)
|
||||
{
|
||||
if(adv_record[i].ter_con_handle == con_handle) {
|
||||
@@ -798,7 +667,7 @@ tBTM_STATUS BTM_BlePeriodicAdvCfgDataRaw(UINT8 instance, UINT16 len, UINT8 *data
|
||||
}
|
||||
}
|
||||
|
||||
if ((err = btsnd_hcic_ble_set_periodic_adv_data(instance, operation, send_data_len, &data[data_offset])) != HCI_SUCCESS) {
|
||||
if ((err = btsnd_hcic_ble_set_periodic_adv_data(instance, operation, send_data_len, (data == NULL)? NULL : &data[data_offset])) != HCI_SUCCESS) {
|
||||
BTM_TRACE_ERROR("LE PA SetData: cmd err=0x%x", err);
|
||||
status = BTM_HCI_ERROR | err;
|
||||
break;
|
||||
@@ -900,7 +769,7 @@ tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params)
|
||||
sync_retry_cb.in_use = true;
|
||||
#endif // #if (BLE_FEAT_CREATE_SYNC_RETRY_MAX > 0)
|
||||
if (!btsnd_hcic_ble_periodic_adv_create_sync(option, params->sid, params->addr_type,
|
||||
params->addr, params->sync_timeout, params->sync_cte_type)) {
|
||||
params->addr, params->skip, params->sync_timeout, params->sync_cte_type)) {
|
||||
BTM_TRACE_ERROR("LE PA CreateSync cmd failed");
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
#if (BLE_FEAT_CREATE_SYNC_RETRY_MAX > 0)
|
||||
@@ -1097,7 +966,7 @@ tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params)
|
||||
phy_count++;
|
||||
}
|
||||
|
||||
if (BTM_BleUpdateOwnType(¶ms->own_addr_type, NULL) != 0 ) {
|
||||
if (BTM_BleUpdateOwnType(¶ms->own_addr_type) != 0 ) {
|
||||
status = BTM_ILLEGAL_VALUE;
|
||||
BTM_TRACE_ERROR("LE UpdateOwnType err");
|
||||
goto end;
|
||||
@@ -1310,7 +1179,7 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params)
|
||||
if(params->status == 0x00) {
|
||||
adv_record[params->adv_handle].ter_con_handle = params->conn_handle;
|
||||
} else {
|
||||
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE;
|
||||
adv_record[params->adv_handle].ter_con_handle = INVALID_VALUE_16BIT;
|
||||
adv_record[params->adv_handle].invalid = false;
|
||||
}
|
||||
adv_record[params->adv_handle].enabled = false;
|
||||
@@ -1573,6 +1442,7 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par
|
||||
sync_retry_cb.params.sid,
|
||||
sync_retry_cb.params.addr_type,
|
||||
sync_retry_cb.params.addr,
|
||||
sync_retry_cb.params.skip,
|
||||
sync_retry_cb.params.sync_timeout,
|
||||
sync_retry_cb.params.sync_cte_type)) {
|
||||
/* Retry command sent successfully, wait for next event */
|
||||
@@ -2110,6 +1980,7 @@ void btm_ble_cs_security_enable_cmd_status(UINT8 status)
|
||||
tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT cs_security_enable = {0};
|
||||
if (status != HCI_SUCCESS) {
|
||||
cs_security_enable.status = (status | BTM_HCI_ERROR);
|
||||
cs_security_enable.conn_handle = 0xFFFF; // Invalid handle
|
||||
BTM_ExtBleCallbackTrigger(BTM_BLE_GAP_CS_SECURITY_ENABLE_CMPL_EVT, (tBTM_BLE_5_GAP_CB_PARAMS *)&cs_security_enable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
#include "btm_ble_int.h"
|
||||
#include "stack/smp_api.h"
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -50,6 +51,7 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
|
||||
{
|
||||
tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||
BTM_TRACE_EVENT ("btm_gen_resolve_paddr_cmpl");
|
||||
tBTM_STATUS status = BTM_SUCCESS;
|
||||
|
||||
if (p) {
|
||||
/* set hash to be LSB of rpAddress */
|
||||
@@ -62,10 +64,7 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
|
||||
|
||||
p_cb->exist_addr_bit |= BTM_BLE_GAP_ADDR_BIT_RESOLVABLE;
|
||||
memcpy(p_cb->resolvale_addr, p_cb->private_addr, BD_ADDR_LEN);
|
||||
if (p_cb->set_local_privacy_cback){
|
||||
(*p_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_SUCCESS);
|
||||
p_cb->set_local_privacy_cback = NULL;
|
||||
}
|
||||
status = BTM_SET_PRIVACY_SUCCESS;
|
||||
|
||||
/* start a periodical timer to refresh random addr */
|
||||
btu_stop_timer_oneshot(&p_cb->raddr_timer_ent);
|
||||
@@ -79,11 +78,11 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p)
|
||||
} else {
|
||||
/* random address set failure */
|
||||
BTM_TRACE_DEBUG("set random address failed");
|
||||
if (p_cb->set_local_privacy_cback){
|
||||
(*p_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL);
|
||||
p_cb->set_local_privacy_cback = NULL;
|
||||
}
|
||||
status = BTM_SET_PRIVACY_FAIL;
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_BleLegacyGapOneshotFireIfArmed(BTM_BLE_LEGACY_GAP_SET_PRIVACY_EVT, &cb_params);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -221,7 +220,7 @@ static void btm_ble_resolve_address_cmpl(void)
|
||||
{
|
||||
tBTM_LE_RANDOM_CB *p_mgnt_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||
|
||||
BTM_TRACE_EVENT ("btm_ble_resolve_address_cmpl p_mgnt_cb->p_dev_rec = 0x%08x", (uint32_t)p_mgnt_cb->p_dev_rec);
|
||||
BTM_TRACE_EVENT ("btm_ble_resolve_address_cmpl p_mgnt_cb->p_dev_rec = 0x%08x", p_mgnt_cb->p_dev_rec ? (uint32_t)p_mgnt_cb->p_dev_rec : 0);
|
||||
|
||||
p_mgnt_cb->busy = FALSE;
|
||||
|
||||
@@ -405,7 +404,9 @@ void btm_ble_resolve_random_addr(BD_ADDR random_bda, tBTM_BLE_RESOLVE_CBACK *p_c
|
||||
p_dev_rec = list_node(p_node);
|
||||
p_mgnt_cb->p_dev_rec = p_dev_rec;
|
||||
if (btm_ble_match_random_bda(p_dev_rec)) {
|
||||
break;
|
||||
// if matched, btm_ble_match_random_bda->btm_ble_proc_resolve_x->btm_ble_resolve_address_cmpl
|
||||
p_mgnt_cb->p_dev_rec = NULL;
|
||||
return;
|
||||
}
|
||||
p_mgnt_cb->p_dev_rec = NULL;
|
||||
}
|
||||
@@ -439,12 +440,12 @@ tBTM_SEC_DEV_REC *btm_find_dev_by_identity_addr(BD_ADDR bd_addr, UINT8 addr_type
|
||||
context.free_check = FALSE;
|
||||
p_node = list_foreach(btm_cb.p_sec_dev_rec_list, btm_find_sec_dev_in_list, &context);
|
||||
if (p_node) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
p_dev_rec = list_node(p_node);
|
||||
if ((p_dev_rec->ble.static_addr_type & (~BLE_ADDR_TYPE_ID_BIT)) !=
|
||||
(addr_type & (~BLE_ADDR_TYPE_ID_BIT))) {
|
||||
BTM_TRACE_WARNING("%s find pseudo->random match with diff addr type: %d vs %d",
|
||||
__func__, p_dev_rec->ble.static_addr_type, addr_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
return p_dev_rec;
|
||||
#endif
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "l2c_int.h"
|
||||
#include "stack/hcimsgs.h"
|
||||
//#include "bt_utils.h"
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
#ifndef BTM_BLE_SCAN_PARAM_TOUT
|
||||
#define BTM_BLE_SCAN_PARAM_TOUT 50 /* 50 seconds */
|
||||
@@ -278,8 +279,11 @@ void btm_enq_wl_dev_operation(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE ad
|
||||
** the white list.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type)
|
||||
{
|
||||
BOOLEAN result = TRUE;
|
||||
UINT8 status;
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params;
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
if (addr_type > BLE_ADDR_RANDOM && addr_type != BLE_ADDR_ANONYMOUS)
|
||||
#else
|
||||
@@ -287,10 +291,9 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
{
|
||||
BTM_TRACE_ERROR("%s address type is error, unable to add device", __func__);
|
||||
if (update_wl_cb){
|
||||
update_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
|
||||
}
|
||||
return FALSE;
|
||||
status = HCI_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
result = FALSE;
|
||||
goto _wl_end;
|
||||
}
|
||||
|
||||
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
|
||||
@@ -319,10 +322,9 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
// do nothing
|
||||
} else {
|
||||
BTC_TRACE_ERROR(" controller not support resolvable address");
|
||||
if (update_wl_cb){
|
||||
update_wl_cb(HCI_ERR_ILLEGAL_PARAMETER_FMT,to_add);
|
||||
}
|
||||
return FALSE;
|
||||
status = HCI_ERR_ILLEGAL_PARAMETER_FMT;
|
||||
result = FALSE;
|
||||
goto _wl_end;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -331,10 +333,9 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
|
||||
if (to_add && p_cb->white_list_avail_size == 0) {
|
||||
BTM_TRACE_ERROR("%s Whitelist full, unable to add device", __func__);
|
||||
if (update_wl_cb){
|
||||
update_wl_cb(HCI_ERR_MEMORY_FULL,to_add);
|
||||
}
|
||||
return FALSE;
|
||||
status = HCI_ERR_MEMORY_FULL;
|
||||
result = FALSE;
|
||||
goto _wl_end;
|
||||
}
|
||||
|
||||
#if (BLE_GATT_BGCONN == TRUE)
|
||||
@@ -342,27 +343,21 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
/* added the bd_addr to the connection hash map queue */
|
||||
if(!background_connection_add((bt_bdaddr_t *)bd_addr)) {
|
||||
/* if the bd_addr already exist in whitelist, just callback return TRUE */
|
||||
if (update_wl_cb){
|
||||
update_wl_cb(HCI_SUCCESS,to_add);
|
||||
}
|
||||
return TRUE;
|
||||
status = HCI_SUCCESS;
|
||||
result = TRUE;
|
||||
goto _wl_end;
|
||||
}
|
||||
} else {
|
||||
/* remove the bd_addr to the connection hash map queue */
|
||||
if(!background_connection_remove((bt_bdaddr_t *)bd_addr)){
|
||||
/* if the bd_addr don't exist in whitelist, just callback return TRUE */
|
||||
if (update_wl_cb){
|
||||
update_wl_cb(HCI_SUCCESS,to_add);
|
||||
}
|
||||
return TRUE;
|
||||
status = HCI_SUCCESS;
|
||||
result = TRUE;
|
||||
goto _wl_end;
|
||||
}
|
||||
}
|
||||
#endif // (BLE_GATT_BGCONN == TRUE)
|
||||
|
||||
if (update_wl_cb){
|
||||
//save add whitelist complete callback
|
||||
p_cb->update_wl_cb = update_wl_cb;
|
||||
}
|
||||
/* stop the auto connect */
|
||||
btm_suspend_wl_activity(p_cb->wl_state);
|
||||
/* save the bd_addr to the btm_cb env */
|
||||
@@ -370,6 +365,13 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
/* save the ba_addr to the controller white list */
|
||||
btm_wl_update_to_controller();
|
||||
return TRUE;
|
||||
|
||||
_wl_end:
|
||||
memset(&cb_params, 0, sizeof(cb_params));
|
||||
cb_params.white_list_update.status = status;
|
||||
cb_params.white_list_update.operation = to_add ? BTM_WHITELIST_ADD : BTM_WHITELIST_REMOVE;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_WHITE_LIST_UPDATE_EVT, &cb_params);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -379,20 +381,14 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_
|
||||
** Description This function clears the white list.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb)
|
||||
void btm_ble_clear_white_list (void)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
|
||||
BTM_TRACE_EVENT ("btm_ble_clear_white_list");
|
||||
btsnd_hcic_ble_clear_white_list();
|
||||
|
||||
#if (BLE_GATT_BGCONN == TRUE)
|
||||
background_connections_clear();
|
||||
#endif // (BLE_GATT_BGCONN == TRUE)
|
||||
|
||||
if (update_wl_cb) {
|
||||
p_cb->update_wl_cb = update_wl_cb;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -417,9 +413,10 @@ void btm_ble_clear_white_list_complete(UINT8 *p_data, UINT16 evt_len)
|
||||
BTM_TRACE_ERROR ("%s failed, status 0x%x\n", __func__, status);
|
||||
}
|
||||
|
||||
if (p_cb->update_wl_cb) {
|
||||
(*p_cb->update_wl_cb)(status, BTM_WHITELIST_CLEAR);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.white_list_update.status = status;
|
||||
cb_params.white_list_update.operation = BTM_WHITELIST_CLEAR;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_WHITE_LIST_UPDATE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -462,7 +459,6 @@ void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size)
|
||||
void btm_ble_add_2_white_list_complete(UINT8 status)
|
||||
{
|
||||
BTM_TRACE_EVENT("%s status=%d", __func__, status);
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
if (status == HCI_SUCCESS) {
|
||||
// --btm_cb.ble_ctr_cb.white_list_avail_size;
|
||||
/*
|
||||
@@ -475,10 +471,10 @@ void btm_ble_add_2_white_list_complete(UINT8 status)
|
||||
*/
|
||||
}
|
||||
// add whitelist complete callback
|
||||
if (p_cb->update_wl_cb)
|
||||
{
|
||||
(*p_cb->update_wl_cb)(status, BTM_WHITELIST_ADD);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.white_list_update.status = status;
|
||||
cb_params.white_list_update.operation = BTM_WHITELIST_ADD;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_WHITE_LIST_UPDATE_EVT, &cb_params);
|
||||
|
||||
}
|
||||
|
||||
@@ -491,16 +487,16 @@ void btm_ble_add_2_white_list_complete(UINT8 status)
|
||||
*******************************************************************************/
|
||||
void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
|
||||
UNUSED(evt_len);
|
||||
BTM_TRACE_EVENT ("%s status=%d", __func__, *p);
|
||||
if (*p == HCI_SUCCESS) {
|
||||
// ++btm_cb.ble_ctr_cb.white_list_avail_size;
|
||||
}
|
||||
if (p_cb->update_wl_cb)
|
||||
{
|
||||
(*p_cb->update_wl_cb)(*p, BTM_WHITELIST_REMOVE);
|
||||
}
|
||||
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.white_list_update.status = *p;
|
||||
cb_params.white_list_update.operation = BTM_WHITELIST_REMOVE;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_WHITE_LIST_UPDATE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
#if (BLE_GATT_BGCONN == TRUE)
|
||||
@@ -619,11 +615,11 @@ BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cb
|
||||
|
||||
/* Process advertising packets only from devices in the white list */
|
||||
/* use passive scan by default */
|
||||
if (!btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS,
|
||||
scan_int,
|
||||
scan_win,
|
||||
p_cb->addr_mgnt_cb.own_addr_type,
|
||||
SP_ADV_WL)) {
|
||||
if (btsnd_hcic_ble_set_scan_params(BTM_BLE_SCAN_MODE_PASS,
|
||||
scan_int,
|
||||
scan_win,
|
||||
p_cb->addr_mgnt_cb.own_addr_type,
|
||||
SP_ADV_WL) != HCI_SUCCESS) {
|
||||
return FALSE;
|
||||
}
|
||||
#if (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
@@ -636,7 +632,7 @@ BOOLEAN btm_ble_start_select_conn(BOOLEAN start, tBTM_BLE_SEL_CBACK *p_select_cb
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
|
||||
#endif
|
||||
if (!btsnd_hcic_ble_set_scan_enable(TRUE, TRUE)) { /* duplicate filtering enabled */
|
||||
if (btsnd_hcic_ble_set_scan_enable(TRUE, TRUE) != HCI_SUCCESS) { /* duplicate filtering enabled */
|
||||
return FALSE;
|
||||
}
|
||||
/* mark up inquiry status flag */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -46,7 +46,7 @@ void btm_ble_iso_read_iso_tx_sync_complete(UINT8 *p)
|
||||
if (cb_params.btm_read_tx_sync.status != HCI_SUCCESS) {
|
||||
cb_params.btm_read_tx_sync.status = (BTM_HCI_ERROR | cb_params.btm_read_tx_sync.status);
|
||||
}
|
||||
cb_params.btm_read_tx_sync.conn_hdl = (cb_params.btm_read_tx_sync.conn_hdl & 0xEFF);
|
||||
cb_params.btm_read_tx_sync.conn_hdl = (cb_params.btm_read_tx_sync.conn_hdl & 0x0FFF);
|
||||
cb_params.btm_read_tx_sync.time_offset = (cb_params.btm_read_tx_sync.time_offset & 0xFFFFFF);
|
||||
BTM_TRACE_DEBUG("read tx sync cmpl, status 0x%x conn_hdl 0x%x pkt_seq_num %d tx_time_stamp %ld time_offset %ld\n",
|
||||
cb_params.btm_read_tx_sync.status, cb_params.btm_read_tx_sync.conn_hdl, cb_params.btm_read_tx_sync.pkt_seq_num,
|
||||
@@ -162,7 +162,7 @@ void btm_ble_cis_request_evt(tBTM_BLE_CIS_REQUEST_CMPL *params)
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
void btm_ble_big_create_cmpl_evt(tBTM_BLE_BIG_CREATE_CMPL *params)
|
||||
{
|
||||
BTM_TRACE_DEBUG("%s", __func__);
|
||||
@@ -217,7 +217,7 @@ void btm_ble_big_terminate_cmpl_evt(tBTM_BLE_BIG_TERMINATE_CMPL *params)
|
||||
|
||||
BTM_IsoBleCallbackTrigger(BTM_BLE_ISO_BIG_TERMINATE_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
void btm_ble_big_sync_estab_evt(tBTM_BLE_BIG_SYNC_ESTAB_CMPL *params)
|
||||
@@ -315,7 +315,7 @@ void btm_ble_iso_data_path_update_complete(UINT16 opcode, UINT8 hci_status, UINT
|
||||
BTM_IsoBleCallbackTrigger(BTM_BLE_ISO_DATA_PATH_UPFATE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
tBTM_STATUS BTM_BleBigCreate(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
|
||||
uint32_t sdu_interval, uint16_t max_sdu, uint16_t max_transport_latency,
|
||||
uint8_t rtn, uint8_t phy, uint8_t packing, uint8_t framing,
|
||||
@@ -356,23 +356,11 @@ tBTM_STATUS BTM_BleBigCreateTest(uint8_t big_handle, uint8_t adv_handle, uint8_t
|
||||
|
||||
tBTM_STATUS BTM_BleBigTerminate(UINT8 big_handle, UINT8 reason)
|
||||
{
|
||||
tHCI_STATUS err = HCI_SUCCESS;
|
||||
tBTM_STATUS status = BTM_SUCCESS;
|
||||
tBTM_BLE_ISO_CB_PARAMS cb_params = {0};
|
||||
|
||||
if ((err = btsnd_hcic_ble_big_terminate(big_handle, reason)) != TRUE) {
|
||||
BTM_TRACE_ERROR("LE PA SyncCancel, cmd err=0x%x", err);
|
||||
status = BTM_HCI_ERROR | err;
|
||||
}
|
||||
|
||||
if (status != BTM_SUCCESS) {
|
||||
cb_params.status = status;
|
||||
BTM_IsoBleCallbackTrigger(BTM_BLE_ISO_BIG_TERMINATE_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
return status;
|
||||
// event will be triggered in command status and complete event
|
||||
btsnd_hcic_ble_big_terminate(big_handle, reason);
|
||||
return BTM_SUCCESS;
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
tBTM_STATUS BTM_BleBigSyncCreate(uint8_t big_handle, uint16_t sync_handle,
|
||||
@@ -488,6 +476,11 @@ tBTM_STATUS BTM_BleSetCigParams(uint8_t cig_id, uint32_t sdu_int_c_to_p, uint32_
|
||||
BTM_TRACE_ERROR("%s, cis_cnt %d exceeds BLE_ISO_CIS_MAX_COUNT %d", __func__, cis_cnt, BLE_ISO_CIS_MAX_COUNT);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
// HCI_LE_Set_CIG_Parameters param length = 15 + 9*cis_cnt (UINT8). Max 255 => cis_cnt <= 26.
|
||||
if (cis_cnt > 26) {
|
||||
BTM_TRACE_ERROR("%s, cis_cnt %d exceeds HCI transport limit", __func__, cis_cnt);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
if ((err = btsnd_hcic_ble_iso_set_cig_params(cig_id, sdu_int_c_to_p, sdu_int_p_to_c, worse_case_SCA, packing,
|
||||
framing, mtl_c_to_p, mtl_p_to_c, cis_cnt, (struct ble_hci_le_cis_params *)cis_params)) != HCI_SUCCESS) {
|
||||
@@ -508,6 +501,11 @@ tBTM_STATUS BTM_BleSetCigParamsTest(uint8_t cig_id, uint32_t sdu_int_c_to_p, uin
|
||||
BTM_TRACE_ERROR("%s, cis_cnt %d exceeds BLE_ISO_CIS_MAX_COUNT %d", __func__, cis_cnt, BLE_ISO_CIS_MAX_COUNT);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
// HCI_LE_Set_CIG_Parameters_Test param length = 15 + 14*cis_cnt (UINT8). Max 255 => cis_cnt <= 17.
|
||||
if (cis_cnt > 17) {
|
||||
BTM_TRACE_ERROR("%s, cis_cnt %d exceeds HCI transport limit", __func__, cis_cnt);
|
||||
return BTM_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
if ((err = btsnd_hcic_ble_iso_set_cig_params_test(cig_id, sdu_int_c_to_p, sdu_int_p_to_c,ft_c_to_p, ft_p_to_c, iso_interval,
|
||||
worse_case_SCA, packing, framing, cis_cnt, (struct ble_hci_le_cis_params_test *)cis_params)) != HCI_SUCCESS) {
|
||||
@@ -562,8 +560,14 @@ void btm_ble_accept_cis_req_cmd_status(tBTM_BLE_ISO_CB_PARAMS *cb_params)
|
||||
|
||||
tBTM_STATUS BTM_BleAcceptCisReq(uint16_t cis_handle)
|
||||
{
|
||||
btsnd_hcic_ble_iso_accept_cis_req(cis_handle);
|
||||
return BTM_SUCCESS;
|
||||
if (btsnd_hcic_ble_iso_accept_cis_req(cis_handle)) {
|
||||
return BTM_SUCCESS;
|
||||
}
|
||||
// failed to send command
|
||||
tBTM_BLE_ISO_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = BTM_NO_RESOURCES;
|
||||
btm_ble_accept_cis_req_cmd_status(&cb_params);
|
||||
return BTM_NO_RESOURCES;
|
||||
}
|
||||
|
||||
tBTM_STATUS BTM_BleRejectCisReq(uint16_t cis_handle, uint8_t reason)
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include "btm_int.h"
|
||||
#include "device/controller.h"
|
||||
#include "stack/hcidefs.h"
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
#define HCI_VENDOR_BLE_RPA_VSC (0x0155 | HCI_GRP_VENDOR_SPECIFIC)
|
||||
|
||||
@@ -49,6 +50,7 @@
|
||||
#define BTM_BLE_META_CLEAR_IRK_LEN 1
|
||||
#define BTM_BLE_META_READ_IRK_LEN 2
|
||||
#define BTM_BLE_META_ADD_WL_ATTR_LEN 9
|
||||
#define BTM_BLE_IRK_LIST_INVALID_INDEX 0xFF
|
||||
|
||||
#if CONTROLLER_RPA_LIST_ENABLE && BLE_SMP_ID_RESET_ENABLE
|
||||
static bool is_deleting_zero_addr;
|
||||
@@ -71,7 +73,14 @@ static bool is_deleting_zero_addr;
|
||||
void btm_ble_enq_resolving_list_pending(BD_ADDR pseudo_bda, UINT8 op_code)
|
||||
{
|
||||
tBTM_BLE_RESOLVE_Q *p_q = &btm_cb.ble_ctr_cb.resolving_list_pend_q;
|
||||
|
||||
UINT8 max_size = controller_get_interface()->get_ble_resolving_list_max_size();
|
||||
if (max_size <= 1) {
|
||||
return;
|
||||
}
|
||||
if (((p_q->q_next + 1) % max_size) == p_q->q_pending) {
|
||||
BTM_TRACE_ERROR("%s, resolving pending queue full\n", __func__);
|
||||
return;
|
||||
}
|
||||
memcpy(p_q->resolve_q_random_pseudo[p_q->q_next], pseudo_bda, BD_ADDR_LEN);
|
||||
p_q->resolve_q_action[p_q->q_next] = op_code;
|
||||
p_q->q_next ++;
|
||||
@@ -159,7 +168,7 @@ void btm_ble_clear_irk_index(UINT8 index)
|
||||
**
|
||||
** Description find the first available IRK list index
|
||||
**
|
||||
** Returns index from 0 ~ max (127 default)
|
||||
** Returns index from 0 ~ max-1, or BTM_BLE_IRK_LIST_INVALID_INDEX if full
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT8 btm_ble_find_irk_index(void)
|
||||
@@ -180,7 +189,7 @@ UINT8 btm_ble_find_irk_index(void)
|
||||
}
|
||||
|
||||
BTM_TRACE_ERROR ("%s failed, list full", __func__);
|
||||
return i;
|
||||
return BTM_BLE_IRK_LIST_INVALID_INDEX;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -202,7 +211,13 @@ void btm_ble_update_resolving_list(BD_ADDR pseudo_bda, BOOLEAN add)
|
||||
if (add) {
|
||||
p_dev_rec->ble.in_controller_list |= BTM_RESOLVING_LIST_BIT;
|
||||
if (!controller_get_interface()->supports_ble_privacy()) {
|
||||
p_dev_rec->ble.resolving_list_index = btm_ble_find_irk_index();
|
||||
UINT8 irk_index = btm_ble_find_irk_index();
|
||||
if (irk_index != BTM_BLE_IRK_LIST_INVALID_INDEX) {
|
||||
p_dev_rec->ble.resolving_list_index = irk_index;
|
||||
} else {
|
||||
p_dev_rec->ble.in_controller_list &= ~BTM_RESOLVING_LIST_BIT;
|
||||
BTM_TRACE_WARNING("%s: IRK list full, cannot add to resolving list", __func__);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
p_dev_rec->ble.in_controller_list &= ~BTM_RESOLVING_LIST_BIT;
|
||||
@@ -244,10 +259,11 @@ void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len)
|
||||
if (controller_get_interface()->get_ble_resolving_list_max_size() == 0) {
|
||||
btm_ble_resolving_list_init(irk_list_sz_max);
|
||||
}
|
||||
|
||||
uint8_t irk_mask_size = (irk_list_sz_max % 8) ?
|
||||
if (btm_cb.ble_ctr_cb.irk_list_mask != NULL) {
|
||||
uint8_t irk_mask_size = (irk_list_sz_max % 8) ?
|
||||
(irk_list_sz_max / 8 + 1) : (irk_list_sz_max / 8);
|
||||
memset(btm_cb.ble_ctr_cb.irk_list_mask, 0, irk_mask_size);
|
||||
memset(btm_cb.ble_ctr_cb.irk_list_mask, 0, irk_mask_size);
|
||||
}
|
||||
}
|
||||
|
||||
btm_cb.ble_ctr_cb.resolving_list_avail_size =
|
||||
@@ -279,14 +295,10 @@ void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len)
|
||||
{
|
||||
UINT8 status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (btm_cb.devcb.p_add_dev_to_resolving_list_cmpl_cb) {
|
||||
tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_cb = btm_cb.devcb.p_add_dev_to_resolving_list_cmpl_cb;
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
} else {
|
||||
BTM_TRACE_DEBUG("no resolving list callback");
|
||||
}
|
||||
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_BleLegacyGapOneshotFireIfArmed(BTM_BLE_LEGACY_GAP_ADD_DEV_TO_RPA_LIST_EVT, &cb_params);
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
@@ -424,21 +436,12 @@ void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len)
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
tBTM_LE_RANDOM_CB *random_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
|
||||
|
||||
if (!(random_cb && random_cb->set_local_privacy_cback)) {
|
||||
return;
|
||||
if (status != HCI_SUCCESS) {
|
||||
BTM_TRACE_ERROR("set local privacy failed with status: 0x%x", status);
|
||||
}
|
||||
|
||||
if (status == HCI_SUCCESS) {
|
||||
random_cb->set_local_privacy_cback(BTM_SUCCESS);
|
||||
return;
|
||||
} else if (status == HCI_ERR_COMMAND_DISALLOWED) {
|
||||
BTM_TRACE_ERROR("a non-connected activity is ongoing, such as advertising and scanning");
|
||||
} else {
|
||||
BTM_TRACE_ERROR("set local privacy failed");
|
||||
}
|
||||
random_cb->set_local_privacy_cback(BTM_ILLEGAL_VALUE);
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = (status == HCI_SUCCESS)? BTM_SUCCESS : BTM_ILLEGAL_VALUE;
|
||||
BTM_BleLegacyGapOneshotFireIfArmed(BTM_BLE_LEGACY_GAP_SET_PRIVACY_EVT, &cb_params);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -463,11 +466,9 @@ void btm_ble_set_rpa_timeout_complete(UINT8 *p, UINT16 evt_len)
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = %d", __func__, status);
|
||||
|
||||
tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_cb = btm_cb.devcb.p_ble_set_rpa_timeout_cmpl_cb;
|
||||
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_RPA_TIMEOUT_EVT, &cb_params);
|
||||
|
||||
}
|
||||
|
||||
@@ -492,11 +493,9 @@ void btm_ble_set_privacy_mode_complete(UINT8 *p, UINT16 evt_len)
|
||||
|
||||
BTM_TRACE_DEBUG("%s status = 0x%x", __func__, status);
|
||||
|
||||
tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_cb = btm_cb.devcb.p_set_privacy_mode_cmpl_cb;
|
||||
|
||||
if (p_cb) {
|
||||
(*p_cb)(status);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_SET_PRIVACY_MODE_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
#if (0)
|
||||
@@ -709,8 +708,9 @@ BOOLEAN btm_ble_suspend_resolving_list_activity(void)
|
||||
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
if (p_ble_cb->inq_var.adv_mode == BTM_BLE_ADV_ENABLE) {
|
||||
btm_ble_stop_adv();
|
||||
p_ble_cb->suspended_rl_state |= BTM_BLE_RL_ADV;
|
||||
if (btm_ble_stop_adv() == BTM_SUCCESS) {
|
||||
p_ble_cb->suspended_rl_state |= BTM_BLE_RL_ADV;
|
||||
}
|
||||
}
|
||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||
|
||||
@@ -1124,14 +1124,31 @@ void btm_ble_resolving_list_init(UINT8 max_irk_list_sz)
|
||||
tBTM_BLE_RESOLVE_Q *p_q = &btm_cb.ble_ctr_cb.resolving_list_pend_q;
|
||||
UINT8 irk_mask_size = (max_irk_list_sz % 8) ?
|
||||
(max_irk_list_sz / 8 + 1) : (max_irk_list_sz / 8);
|
||||
// free them if they are already allocated.
|
||||
btm_ble_resolving_list_cleanup();
|
||||
|
||||
p_q->q_next = 0;
|
||||
p_q->q_pending = 0;
|
||||
|
||||
if (max_irk_list_sz > 0) {
|
||||
p_q->resolve_q_random_pseudo = (BD_ADDR *)osi_malloc(sizeof(BD_ADDR) * max_irk_list_sz);
|
||||
if (p_q->resolve_q_random_pseudo == NULL) {
|
||||
BTM_TRACE_ERROR("%s - Out of memory for random pseudo address", __FUNCTION__);
|
||||
goto _mem_error;
|
||||
}
|
||||
p_q->resolve_q_action = (UINT8 *)osi_malloc(max_irk_list_sz);
|
||||
if (p_q->resolve_q_action == NULL) {
|
||||
BTM_TRACE_ERROR("%s - Out of memory for resolve action", __FUNCTION__);
|
||||
goto _mem_error;
|
||||
}
|
||||
|
||||
/* RPA offloading feature */
|
||||
if (btm_cb.ble_ctr_cb.irk_list_mask == NULL) {
|
||||
btm_cb.ble_ctr_cb.irk_list_mask = (UINT8 *)osi_malloc(irk_mask_size);
|
||||
if (btm_cb.ble_ctr_cb.irk_list_mask == NULL) {
|
||||
BTM_TRACE_ERROR("%s - Out of memory for IRK list mask", __FUNCTION__);
|
||||
goto _mem_error;
|
||||
}
|
||||
}
|
||||
|
||||
BTM_TRACE_DEBUG ("%s max_irk_list_sz = %d", __func__, max_irk_list_sz);
|
||||
@@ -1140,6 +1157,12 @@ void btm_ble_resolving_list_init(UINT8 max_irk_list_sz)
|
||||
controller_get_interface()->set_ble_resolving_list_max_size(max_irk_list_sz);
|
||||
btm_ble_clear_resolving_list();
|
||||
btm_cb.ble_ctr_cb.resolving_list_avail_size = max_irk_list_sz;
|
||||
|
||||
return;
|
||||
|
||||
_mem_error:
|
||||
btm_ble_resolving_list_cleanup();
|
||||
btm_cb.ble_ctr_cb.resolving_list_avail_size = 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#include "gatt_int.h"
|
||||
#endif /* BLE_INCLUDED */
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
//extern thread_t *bt_workqueue_thread;
|
||||
|
||||
@@ -769,7 +770,6 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
tBTM_CMPL_CB *p_vsc_cplt_cback)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb;
|
||||
switch(opcode) {
|
||||
case HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST: {
|
||||
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
@@ -777,34 +777,38 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
|
||||
STREAM_TO_UINT8(status, p);
|
||||
STREAM_TO_UINT8(subcode, p);
|
||||
STREAM_TO_UINT32(length, p);
|
||||
if(ble_cb && ble_cb->update_exceptional_list_cmp_cb) {
|
||||
(*ble_cb->update_exceptional_list_cmp_cb)(status, subcode, length, p);
|
||||
}
|
||||
break;
|
||||
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.exception_list_up.status = status;
|
||||
cb_params.exception_list_up.subcode = subcode;
|
||||
cb_params.exception_list_up.length = length;
|
||||
cb_params.exception_list_up.device_info = p;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_EXCEPTION_LIST_UPDATE_EVT, &cb_params);
|
||||
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
break;
|
||||
}
|
||||
case HCI_VENDOR_BLE_CLEAR_ADV: {
|
||||
uint8_t status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (ble_cb && ble_cb->inq_var.p_clear_adv_cb) {
|
||||
ble_cb->inq_var.p_clear_adv_cb(status);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_CLEAR_ADV_COMPLETE_EVT, &cb_params);
|
||||
break;
|
||||
}
|
||||
case HCI_VENDOR_BLE_SET_CSA_SUPPORT: {
|
||||
uint8_t status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (ble_cb && ble_cb->set_csa_support_cmpl_cb) {
|
||||
ble_cb->set_csa_support_cmpl_cb(status);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_SET_CSA_SUPPORT_COMPLETE_EVT, &cb_params);
|
||||
break;
|
||||
}
|
||||
case HCI_VENDOR_BLE_SET_EVT_MASK: {
|
||||
uint8_t status;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
if (ble_cb && ble_cb->set_vendor_evt_mask_cmpl_cb) {
|
||||
ble_cb->set_vendor_evt_mask_cmpl_cb(status);
|
||||
}
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.status = status;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_SET_VENDOR_EVT_MASK_COMPLETE_EVT, &cb_params);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -1286,20 +1290,12 @@ void btm_set_afh_channels_complete (UINT8 *p)
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback)
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels)
|
||||
{
|
||||
if (!controller_get_interface()->get_is_ready()) {
|
||||
return (BTM_DEV_RESET);
|
||||
}
|
||||
|
||||
/* Check if set afh already in progress */
|
||||
if (btm_cb.devcb.p_ble_channels_cmpl_cb) {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
|
||||
/* Save callback */
|
||||
btm_cb.devcb.p_ble_channels_cmpl_cb = p_ble_channels_cmpl_cback;
|
||||
|
||||
if (!btsnd_hcic_ble_set_channels (channels)) {
|
||||
return (BTM_NO_RESOURCES);
|
||||
}
|
||||
@@ -1321,30 +1317,24 @@ tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_chann
|
||||
*******************************************************************************/
|
||||
void btm_ble_set_channels_complete (UINT8 *p)
|
||||
{
|
||||
tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_ble_channels_cmpl_cb;
|
||||
tBTM_BLE_SET_CHANNELS_RESULTS results;
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
|
||||
btu_free_timer (&btm_cb.devcb.ble_channels_timer);
|
||||
|
||||
/* If there is a callback address for setting AFH channels, call it */
|
||||
btm_cb.devcb.p_ble_channels_cmpl_cb = NULL;
|
||||
STREAM_TO_UINT8 (cb_params.set_channels.hci_status, p);
|
||||
|
||||
if (p_cb) {
|
||||
STREAM_TO_UINT8 (results.hci_status, p);
|
||||
|
||||
switch (results.hci_status){
|
||||
case HCI_SUCCESS:
|
||||
results.status = BTM_SUCCESS;
|
||||
break;
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
results.status = BTM_ILLEGAL_VALUE;
|
||||
break;
|
||||
default:
|
||||
results.status = BTM_ERR_PROCESSING;
|
||||
break;
|
||||
}
|
||||
(*p_cb)(&results);
|
||||
switch (cb_params.set_channels.hci_status){
|
||||
case HCI_SUCCESS:
|
||||
cb_params.set_channels.status = BTM_SUCCESS;
|
||||
break;
|
||||
case HCI_ERR_UNSUPPORTED_VALUE:
|
||||
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
|
||||
cb_params.set_channels.status = BTM_ILLEGAL_VALUE;
|
||||
break;
|
||||
default:
|
||||
cb_params.set_channels.status = BTM_ERR_PROCESSING;
|
||||
break;
|
||||
}
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_SET_CHANNELS_COMPLETE_EVT, &cb_params);
|
||||
}
|
||||
#endif /// BLE_INCLUDED == TRUE
|
||||
|
||||
@@ -88,7 +88,6 @@ void btm_init (void)
|
||||
btm_dev_init(); /* Device Manager Structures & HCI_Reset */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
btm_ble_lock_init();
|
||||
btm_ble_sem_init();
|
||||
#if ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
btm_cb.addr_res_en = TRUE;
|
||||
#endif // ((SMP_INCLUDED == TRUE) || (BLE_PRIVACY_SPT == TRUE))
|
||||
@@ -131,7 +130,6 @@ void btm_free(void)
|
||||
#endif
|
||||
#if BLE_INCLUDED == TRUE
|
||||
btm_ble_lock_free();
|
||||
btm_ble_sem_free();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -322,7 +322,7 @@ void btm_sco_check_send_pkts (UINT16 sco_inx)
|
||||
}
|
||||
}
|
||||
|
||||
void btm_sco_process_num_completed_pkts (UINT8 *p)
|
||||
void btm_sco_process_num_completed_pkts (UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
UINT8 num_handles, xx;
|
||||
UINT16 handle;
|
||||
@@ -330,7 +330,20 @@ void btm_sco_process_num_completed_pkts (UINT8 *p)
|
||||
UINT16 sco_inx;
|
||||
tSCO_CB *p_cb = &btm_cb.sco_cb;
|
||||
tSCO_CONN * p_ccb;
|
||||
|
||||
if (evt_len < 1) {
|
||||
BTM_TRACE_ERROR ("btm_sco_process_num_completed_pkts: evt too short (len=%u)", evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8 (num_handles, p);
|
||||
|
||||
if (num_handles > (evt_len - 1) / 4) {
|
||||
BTM_TRACE_ERROR ("btm_sco_process_num_completed_pkts: num_handles %u exceeds evt_len %u, truncating",
|
||||
num_handles, evt_len);
|
||||
num_handles = (evt_len - 1) / 4;
|
||||
}
|
||||
|
||||
for (xx = 0; xx < num_handles; xx++) {
|
||||
STREAM_TO_UINT16 (handle, p);
|
||||
STREAM_TO_UINT16 (num_sent, p);
|
||||
|
||||
@@ -3491,6 +3491,12 @@ void btm_io_capabilities_rsp (UINT8 *p)
|
||||
/* Allocate a new device record or reuse the oldest one */
|
||||
p_dev_rec = btm_find_or_alloc_dev (evt_data.bd_addr);
|
||||
|
||||
if (p_dev_rec == NULL) {
|
||||
BTM_TRACE_ERROR ("%s: no device record available\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* If no security is in progress, this indicates incoming security */
|
||||
if (btm_cb.pairing_state == BTM_PAIR_STATE_IDLE) {
|
||||
memcpy (btm_cb.pairing_bda, evt_data.bd_addr, BD_ADDR_LEN);
|
||||
@@ -4337,6 +4343,16 @@ void btm_sec_connected (UINT8 *bda, UINT16 handle, UINT8 status, UINT8 enc_mode)
|
||||
/* There is no device record for new connection. Allocate one */
|
||||
if (status == HCI_SUCCESS) {
|
||||
p_dev_rec = btm_sec_alloc_dev (bda);
|
||||
// no memory to allocate device record
|
||||
if (p_dev_rec == NULL) {
|
||||
if ((btm_cb.pairing_state != BTM_PAIR_STATE_IDLE) &&
|
||||
(memcmp (btm_cb.pairing_bda, bda, BD_ADDR_LEN) == 0)) {
|
||||
btm_sec_change_pairing_state(BTM_PAIR_STATE_IDLE);
|
||||
}
|
||||
BTM_TRACE_ERROR ("%s: no device record available\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
/* If the device matches with stored paring address
|
||||
* reset the paring state to idle */
|
||||
@@ -4899,6 +4915,12 @@ void btm_sec_link_key_notification (UINT8 *p_bda, UINT8 *p_link_key, UINT8 key_t
|
||||
void btm_sec_link_key_request (UINT8 *p_bda)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_or_alloc_dev (p_bda);
|
||||
// no memory to allocate device record
|
||||
if (p_dev_rec == NULL) {
|
||||
btsnd_hcic_link_key_neg_reply (p_bda);
|
||||
BTM_TRACE_ERROR ("%s: no device record available\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
BTM_TRACE_EVENT ("btm_sec_link_key_request() BDA: %02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
p_bda[0], p_bda[1], p_bda[2], p_bda[3], p_bda[4], p_bda[5]);
|
||||
@@ -6011,13 +6033,22 @@ static BOOLEAN btm_sec_queue_encrypt_request (BD_ADDR bd_addr, tBT_TRANSPORT tra
|
||||
tBTM_SEC_CALLBACK *p_callback, void *p_ref_data)
|
||||
{
|
||||
tBTM_SEC_QUEUE_ENTRY *p_e;
|
||||
if (bd_addr == NULL) {
|
||||
BTM_TRACE_ERROR("%s: bd_addr is NULL\n", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
p_e = (tBTM_SEC_QUEUE_ENTRY *)osi_malloc(sizeof(tBTM_SEC_QUEUE_ENTRY) + 1);
|
||||
|
||||
if (p_e) {
|
||||
p_e->psm = 0; /* if PSM 0, encryption request */
|
||||
p_e->p_callback = p_callback;
|
||||
p_e->p_ref_data = (void *)(p_e + 1);
|
||||
*(UINT8 *)p_e->p_ref_data = *(UINT8 *)(p_ref_data);
|
||||
if (p_ref_data != NULL) {
|
||||
p_e->p_ref_data = (void *)(p_e + 1);
|
||||
*(UINT8 *)p_e->p_ref_data = *(UINT8 *)p_ref_data;
|
||||
} else {
|
||||
p_e->p_ref_data = NULL;
|
||||
}
|
||||
p_e->transport = transport;
|
||||
memcpy(p_e->bd_addr, bd_addr, BD_ADDR_LEN);
|
||||
fixed_queue_enqueue(btm_cb.sec_pending_q, p_e, FIXED_QUEUE_MAX_TIMEOUT);
|
||||
@@ -6256,36 +6287,6 @@ BOOLEAN btm_sec_is_le_capable_dev (BD_ADDR bda)
|
||||
return le_capable;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_sec_find_bonded_dev
|
||||
**
|
||||
** Description Find a bonded device starting from the specified index
|
||||
**
|
||||
** Returns TRUE - found a bonded device
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
BOOLEAN btm_sec_find_bonded_dev (UINT8 start_idx, UINT16 *p_found_handle, tBTM_SEC_DEV_REC **p_rec)
|
||||
{
|
||||
BOOLEAN found = FALSE;
|
||||
|
||||
#if (SMP_INCLUDED== TRUE)
|
||||
tBTM_SEC_DEV_REC *p_dev_rec;
|
||||
list_node_t *p_node = NULL;
|
||||
for (p_node = list_begin(btm_cb.p_sec_dev_rec_list); p_node; p_node = list_next(p_node)) {
|
||||
p_dev_rec = list_node(p_node);
|
||||
if (p_dev_rec->ble.key_type || (p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_KNOWN)) {
|
||||
*p_found_handle = p_dev_rec->hci_handle;
|
||||
*p_rec = p_dev_rec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
BTM_TRACE_DEBUG ("%s() found=%d\n", __func__, found);
|
||||
#endif
|
||||
return (found);
|
||||
}
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function btm_sec_use_smp_br_chnl
|
||||
|
||||
@@ -157,9 +157,6 @@ typedef struct {
|
||||
UINT16 adv_interval_max;
|
||||
tBTM_BLE_AFP afp; /* advertising filter policy */
|
||||
tBTM_BLE_SFP sfp; /* scanning filter policy */
|
||||
tBTM_START_ADV_CMPL_CBACK *p_adv_cb;
|
||||
tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cb;
|
||||
tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cb;
|
||||
tBLE_ADDR_TYPE adv_addr_type;
|
||||
UINT8 evt_type;
|
||||
UINT8 adv_mode;
|
||||
@@ -206,7 +203,6 @@ typedef struct {
|
||||
tBTM_BLE_ADDR_CBACK *p_generate_cback;
|
||||
void *p;
|
||||
TIMER_LIST_ENT raddr_timer_ent;
|
||||
tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback;
|
||||
} tBTM_LE_RANDOM_CB;
|
||||
|
||||
#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
|
||||
@@ -358,7 +354,6 @@ typedef struct {
|
||||
/* periodic list information */
|
||||
UINT8 periodic_adv_list_size;
|
||||
#endif //#if (BLE_50_EXTEND_SYNC_EN == TRUE)
|
||||
tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb;
|
||||
tBTM_BLE_WL_STATE wl_state;
|
||||
|
||||
fixed_queue_t *conn_pending_q;
|
||||
@@ -386,13 +381,6 @@ typedef struct {
|
||||
tBTM_BLE_STATE_MASK cur_states; /* bit mask of tBTM_BLE_STATE */
|
||||
UINT8 link_count[2]; /* total link count master and slave*/
|
||||
#endif // (BLE_TOPOLOGY_CHECK == TRUE)
|
||||
#if ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb;
|
||||
#endif // ((BLE_42_SCAN_EN == TRUE) || (BLE_50_EXTEND_SCAN_EN == TRUE))
|
||||
#if (BLE_VENDOR_HCI_EN == TRUE)
|
||||
tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb;
|
||||
tBTM_SET_VENDOR_EVT_MASK_CBACK *set_vendor_evt_mask_cmpl_cb;
|
||||
#endif // (BLE_VENDOR_HCI_EN == TRUE)
|
||||
} tBTM_BLE_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -401,7 +389,7 @@ extern "C" {
|
||||
|
||||
void btm_ble_timeout(TIMER_LIST_ENT *p_tle);
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
void btm_ble_process_adv_pkt (UINT8 *p);
|
||||
void btm_ble_process_adv_pkt (UINT8 *p, UINT8 evt_len);
|
||||
void btm_ble_process_adv_discard_evt(UINT8 *p);
|
||||
void btm_ble_process_direct_adv_pkt (UINT8 *p);
|
||||
bool btm_ble_adv_pkt_ready(void);
|
||||
@@ -464,10 +452,10 @@ void btm_ble_update_sec_key_size(BD_ADDR bd_addr, UINT8 enc_key_size);
|
||||
UINT8 btm_ble_read_sec_key_size(BD_ADDR bd_addr);
|
||||
|
||||
/* white list function */
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
|
||||
BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type);
|
||||
void btm_update_scanner_filter_policy(tBTM_BLE_SFP scan_policy);
|
||||
void btm_update_adv_filter_policy(tBTM_BLE_AFP adv_policy);
|
||||
void btm_ble_clear_white_list (tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
|
||||
void btm_ble_clear_white_list (void);
|
||||
void btm_read_white_list_size_complete(UINT8 *p, UINT16 evt_len);
|
||||
void btm_ble_add_2_white_list_complete(UINT8 status);
|
||||
void btm_ble_remove_from_white_list_complete(UINT8 *p, UINT16 evt_len);
|
||||
@@ -578,10 +566,10 @@ void btm_ble_accept_cis_req_cmd_status(tBTM_BLE_ISO_CB_PARAMS *cb_params);
|
||||
void btm_ble_create_cis_cmd_status(tBTM_BLE_ISO_CB_PARAMS *cb_params);
|
||||
void btm_ble_iso_set_cig_params_complete(UINT8 *p);
|
||||
#endif // #if (BLE_FEAT_ISO_CIG_CENTRAL_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
void btm_ble_big_create_cmpl_evt(tBTM_BLE_BIG_CREATE_CMPL *param);
|
||||
void btm_ble_big_terminate_cmpl_evt(tBTM_BLE_BIG_TERMINATE_CMPL *params);
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
void btm_ble_big_sync_estab_evt(tBTM_BLE_BIG_SYNC_ESTAB_CMPL *params);
|
||||
void btm_ble_big_sync_lost_evt(tBTM_BLE_BIG_SYNC_LOST_EVT *params);
|
||||
|
||||
@@ -158,12 +158,10 @@ UINT8 conn_addr_type; /* local device address type for this co
|
||||
BD_ADDR active_remote_addr; /* remote address used on this connection */
|
||||
UINT8 active_remote_addr_type; /* local device address type for this connection */
|
||||
BD_FEATURES peer_le_features; /* Peer LE Used features mask for the device */
|
||||
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback;
|
||||
tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS data_length_params;
|
||||
BOOLEAN data_len_updating;
|
||||
// data len update cmd cache
|
||||
BOOLEAN data_len_waiting;
|
||||
tBTM_SET_PKT_DATA_LENGTH_CBACK *p_set_data_len_cback_waiting;
|
||||
UINT16 tx_len_waiting;
|
||||
#endif
|
||||
tBTM_PM_MCB *p_pm_mode_db; /* Pointer to PM mode control block per ACL link */
|
||||
@@ -241,7 +239,7 @@ tBTM_CMPL_CB *p_write_iscan_tx_pwr_lvl_cmpl_cb; /* Callback function t
|
||||
#endif // (CLASSIC_BT_INCLUDED == TRUE)
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTM_CMPL_CB *p_ble_ch_map_cmpl_cb; /* Callback function to be called when */
|
||||
BOOLEAN is_ch_map_cb;
|
||||
#endif // #if BLE_INCLUDED == TRUE
|
||||
/* read channel map function completes */
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
@@ -292,15 +290,6 @@ DEV_CLASS dev_class; /* Local device class
|
||||
#if BLE_INCLUDED == TRUE
|
||||
|
||||
TIMER_LIST_ENT ble_channels_timer;
|
||||
tBTM_CMPL_CB *p_ble_channels_cmpl_cb; /* Callback function to be called When
|
||||
ble set host channels is completed */
|
||||
|
||||
tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_ble_set_rpa_timeout_cmpl_cb; /* Callback function to be called When
|
||||
ble set rpa timeout is completed */
|
||||
|
||||
tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_cmpl_cb;
|
||||
|
||||
tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_set_privacy_mode_cmpl_cb;
|
||||
|
||||
tBTM_CMPL_CB *p_le_test_cmd_cmpl_cb; /* Callback function to be called when
|
||||
LE test mode command has been sent successfully */
|
||||
@@ -1053,14 +1042,6 @@ typedef struct {
|
||||
#endif
|
||||
} tBTM_CB;
|
||||
|
||||
typedef struct{
|
||||
//connection parameters update callback
|
||||
tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb;
|
||||
// setting packet data length callback
|
||||
tBTM_SET_PKT_DATA_LENGTH_CBACK *set_pkt_data_length_cb;
|
||||
}tBTM_CallbackFunc;
|
||||
|
||||
extern tBTM_CallbackFunc conn_callback_func;
|
||||
/* security action for L2CAP COC channels */
|
||||
#define BTM_SEC_OK 1
|
||||
#define BTM_SEC_ENCRYPT 2 /* encrypt the link with current key */
|
||||
@@ -1192,7 +1173,7 @@ void btm_pm_proc_ssr_evt (UINT8 *p, UINT16 evt_len);
|
||||
void btm_sco_chk_pend_unpark (UINT8 hci_status, UINT16 hci_handle);
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
void btm_sco_process_num_bufs (UINT16 num_lm_sco_bufs);
|
||||
void btm_sco_process_num_completed_pkts (UINT8 *p);
|
||||
void btm_sco_process_num_completed_pkts (UINT8 *p, UINT8 evt_len);
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE ) */
|
||||
#else
|
||||
#define btm_sco_chk_pend_unpark(hci_status, hci_handle)
|
||||
@@ -1337,7 +1318,6 @@ void btm_sec_set_peer_sec_caps (tACL_CONN *p_acl_cb, tBTM_SEC_DEV_REC *p_dev_rec
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
void btm_sec_clear_ble_keys (tBTM_SEC_DEV_REC *p_dev_rec);
|
||||
BOOLEAN btm_sec_find_bonded_dev (UINT8 start_idx, UINT16 *p_found_handle, tBTM_SEC_DEV_REC **p_rec);
|
||||
BOOLEAN btm_sec_is_a_bonded_dev (BD_ADDR bda);
|
||||
void btm_consolidate_dev(tBTM_SEC_DEV_REC *p_target_rec);
|
||||
BOOLEAN btm_sec_is_le_capable_dev (BD_ADDR bda);
|
||||
@@ -1366,10 +1346,6 @@ void btm_sec_clr_temp_auth_service (BD_ADDR bda);
|
||||
|
||||
void btm_ble_lock_init(void);
|
||||
|
||||
void btm_ble_sem_init(void);
|
||||
|
||||
void btm_ble_sem_free(void);
|
||||
|
||||
void btm_ble_lock_free(void);
|
||||
|
||||
void btm_sec_handle_remote_legacy_auth_cmp(UINT16 handle);
|
||||
|
||||
@@ -100,7 +100,7 @@ static void btu_hcif_hardware_error_evt (UINT8 *p);
|
||||
static void btu_hcif_flush_occured_evt (void);
|
||||
static void btu_hcif_role_change_evt (UINT8 *p);
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p);
|
||||
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p, UINT8 evt_len);
|
||||
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
static void btu_hcif_mode_change_evt (UINT8 *p);
|
||||
@@ -195,16 +195,16 @@ static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p);
|
||||
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
void btu_ble_create_big_cmd_status(UINT8 status);
|
||||
static void btu_ble_big_create_complete_evt(UINT8 *p);
|
||||
static void btu_ble_big_create_complete_evt(UINT8 *p, UINT8 evt_len);
|
||||
void btu_ble_big_terminate_cmd_status(UINT8 status);
|
||||
static void btu_ble_big_terminate_complete_evt(UINT8 *p);
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
static void btu_ble_create_big_sync_cmd_status(UINT8 status);
|
||||
static void btu_ble_big_sync_establish_evt(UINT8 *p);
|
||||
static void btu_ble_big_sync_establish_evt(UINT8 *p, UINT8 evt_len);
|
||||
static void btu_ble_big_sync_lost_evt(UINT8 *p);
|
||||
static void btu_ble_biginfo_adv_report_evt(UINT8 *p);
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
@@ -225,10 +225,10 @@ static void btu_ble_cis_disconnected(UINT16 handle, UINT8 reason);
|
||||
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
static void btu_ble_cte_connless_iq_report_evt(UINT8 *p);
|
||||
static void btu_ble_cte_connless_iq_report_evt(UINT8 *p, UINT8 evt_len);
|
||||
#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE)
|
||||
static void btu_ble_cte_conn_iq_report_evt(UINT8 *p);
|
||||
static void btu_ble_cte_conn_iq_report_evt(UINT8 *p, UINT8 evt_len);
|
||||
static void btu_ble_cte_req_failed_evt(UINT8 *p);
|
||||
#endif // #if (BLE_FEAT_CTE_CONNECTION_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_CTE_EN == TRUE)
|
||||
@@ -244,7 +244,7 @@ static void btu_ble_subrate_change_evt(UINT8 *p);
|
||||
|
||||
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
static void btu_ble_pa_subevt_data_request_evt(UINT8 *p);
|
||||
static void btu_ble_pa_response_report_evt(UINT8 *p);
|
||||
static void btu_ble_pa_response_report_evt(UINT8 *p, UINT8 evt_len);
|
||||
#endif // (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
|
||||
#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
|
||||
@@ -253,24 +253,10 @@ static void btu_ble_cs_read_remote_fae_tab_evt(UINT8 *p);
|
||||
static void btu_ble_cs_security_enable_cmpl_evt(UINT8 *p);
|
||||
static void btu_ble_cs_config_cmpl_evt(UINT8 *p);
|
||||
static void btu_ble_cs_proc_enable_cmpl_evt(UINT8 *p);
|
||||
static void btu_ble_cs_subevt_result_evt(UINT8 *p);
|
||||
static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p);
|
||||
static void btu_ble_cs_subevt_result_evt(UINT8 *p, UINT8 evt_len);
|
||||
static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p, UINT8 evt_len);
|
||||
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
|
||||
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
extern osi_sem_t adv_enable_sem;
|
||||
extern osi_sem_t adv_data_sem;
|
||||
extern osi_sem_t adv_param_sem;
|
||||
extern uint8_t adv_enable_status;
|
||||
extern uint8_t adv_data_status;
|
||||
extern uint8_t adv_param_status;
|
||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
extern osi_sem_t scan_enable_sem;
|
||||
extern osi_sem_t scan_param_sem;
|
||||
extern uint8_t scan_enable_status;
|
||||
extern uint8_t scan_param_status;
|
||||
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -290,9 +276,20 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
#if BLE_INCLUDED == TRUE
|
||||
UINT8 ble_sub_code;
|
||||
#endif
|
||||
if (p_msg->len < 2) {
|
||||
HCI_TRACE_ERROR("%s: HCI event too short (len=%u), dropping", __func__, p_msg->len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8 (hci_evt_code, p);
|
||||
STREAM_TO_UINT8 (hci_evt_len, p);
|
||||
|
||||
if (hci_evt_len > p_msg->len - 2) {
|
||||
HCI_TRACE_ERROR("%s: HCI evt 0x%02x param len %u exceeds buffer (avail=%u), dropping",
|
||||
__func__, hci_evt_code, hci_evt_len, p_msg->len - 2);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (hci_evt_code) {
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
case HCI_INQUIRY_COMP_EVT:
|
||||
@@ -375,7 +372,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
break;
|
||||
#endif // #if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
case HCI_NUM_COMPL_DATA_PKTS_EVT:
|
||||
btu_hcif_num_compl_data_pkts_evt (p);
|
||||
btu_hcif_num_compl_data_pkts_evt (p, hci_evt_len);
|
||||
break;
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
case HCI_MODE_CHANGE_EVT:
|
||||
@@ -472,6 +469,10 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
case HCI_BLE_EVENT:
|
||||
if (hci_evt_len < 1) {
|
||||
HCI_TRACE_ERROR("%s: BLE meta event param len %u invalid (need >= 1), dropping", __func__, hci_evt_len);
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT8 (ble_sub_code, p);
|
||||
hci_evt_len--;
|
||||
HCI_TRACE_DEBUG("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
|
||||
@@ -578,17 +579,17 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
btu_ble_cis_request_evt(p);
|
||||
break;
|
||||
#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
case HCI_BLE_BIG_CREATE_COMPLETE_EVT:
|
||||
btu_ble_big_create_complete_evt(p);
|
||||
btu_ble_big_create_complete_evt(p, hci_evt_len);
|
||||
break;
|
||||
case HCI_BLE_BIG_TERMINATE_COMPLETE_EVT:
|
||||
btu_ble_big_terminate_complete_evt(p);
|
||||
break;
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
case HCI_BLE_BIG_SYNC_ESTABLISHED_EVT:
|
||||
btu_ble_big_sync_establish_evt(p);
|
||||
btu_ble_big_sync_establish_evt(p, hci_evt_len);
|
||||
break;
|
||||
case HCI_BLE_BIG_SYNC_LOST_EVT:
|
||||
btu_ble_big_sync_lost_evt(p);
|
||||
@@ -601,13 +602,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
case HCI_BLE_CONNLESS_IQ_REPORT_EVT:
|
||||
btu_ble_cte_connless_iq_report_evt(p);
|
||||
btu_ble_cte_connless_iq_report_evt(p, hci_evt_len);
|
||||
break;
|
||||
#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE)
|
||||
case HCI_BLE_CONN_IQ_REPORT_EVT:
|
||||
btu_ble_cte_conn_iq_report_evt(p);
|
||||
btu_ble_cte_conn_iq_report_evt(p, hci_evt_len);
|
||||
break;
|
||||
case HCI_BLE_CTE_REQUEST_FAILED_EVT:
|
||||
btu_ble_cte_req_failed_evt(p);
|
||||
@@ -633,7 +634,7 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
btu_ble_pa_subevt_data_request_evt(p);
|
||||
break;
|
||||
case HCI_BLE_PA_RESPONSE_REPORT_EVT:
|
||||
btu_ble_pa_response_report_evt(p);
|
||||
btu_ble_pa_response_report_evt(p, hci_evt_len);
|
||||
break;
|
||||
#endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
#if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
|
||||
@@ -653,10 +654,10 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
|
||||
btu_ble_cs_proc_enable_cmpl_evt(p);
|
||||
break;
|
||||
case HCI_BLE_CS_SUBEVENT_RESULT_EVT:
|
||||
btu_ble_cs_subevt_result_evt(p);
|
||||
btu_ble_cs_subevt_result_evt(p, hci_evt_len);
|
||||
break;
|
||||
case HCI_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT:
|
||||
btu_ble_cs_subevt_result_continue_evt(p);
|
||||
btu_ble_cs_subevt_result_continue_evt(p, hci_evt_len);
|
||||
break;
|
||||
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
|
||||
}
|
||||
@@ -719,7 +720,7 @@ void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf)
|
||||
{
|
||||
if (!p_buf) {
|
||||
@@ -770,8 +771,7 @@ UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf)
|
||||
#endif
|
||||
return btsnd_hcic_ble_get_status();
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#endif // ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1418,7 +1418,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
case HCI_BLE_BIG_TERMINATE_SYNC:
|
||||
UINT16 big_handle;
|
||||
UINT8 big_handle;
|
||||
STREAM_TO_UINT8(status, p);
|
||||
STREAM_TO_UINT8(big_handle, p);
|
||||
btm_ble_big_sync_terminate_complete(status, big_handle);
|
||||
@@ -1521,52 +1521,14 @@ static void btu_hcif_command_complete_evt_on_task(BT_HDR *event)
|
||||
|
||||
static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
|
||||
{
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
command_opcode_t opcode;
|
||||
uint8_t *stream = response->data + response->offset + 3;
|
||||
STREAM_TO_UINT16(opcode, stream);
|
||||
switch (opcode) {
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
case HCI_BLE_WRITE_ADV_DATA:
|
||||
adv_data_status = *stream;
|
||||
osi_sem_give(&adv_data_sem);
|
||||
break;
|
||||
case HCI_BLE_WRITE_SCAN_RSP_DATA:
|
||||
adv_data_status = *stream;
|
||||
osi_sem_give(&adv_data_sem);
|
||||
break;
|
||||
case HCI_BLE_WRITE_ADV_ENABLE: {
|
||||
adv_enable_status = *stream;
|
||||
osi_sem_give(&adv_enable_sem);
|
||||
break;
|
||||
}
|
||||
case HCI_BLE_WRITE_ADV_PARAMS:
|
||||
adv_param_status = *stream;
|
||||
osi_sem_give(&adv_param_sem);
|
||||
break;
|
||||
#endif // #if (BLE_42_ADV_EN == TRUE)
|
||||
#if (BLE_42_SCAN_EN == TRUE)
|
||||
case HCI_BLE_WRITE_SCAN_PARAMS:
|
||||
scan_param_status = *stream;
|
||||
osi_sem_give(&scan_param_sem);
|
||||
break;
|
||||
case HCI_BLE_WRITE_SCAN_ENABLE:
|
||||
scan_enable_status = *stream;
|
||||
osi_sem_give(&scan_enable_sem);
|
||||
break;
|
||||
#endif // #if (BLE_42_SCAN_EN == TRUE)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t));
|
||||
command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0];
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
UINT8 status = 0;
|
||||
stream = response->data + response->offset + 3 + 2; // 2 to skip the event headers, 1 to skip the command credits, 2 to opcode.
|
||||
uint8_t *stream = response->data + response->offset + 3 + 2; // 2 to skip the event headers, 1 to skip the command credits, 2 to opcode.
|
||||
STREAM_TO_UINT8(status, stream);
|
||||
btsnd_hci_ble_set_status(status);
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#endif // #if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
HCI_TRACE_DEBUG("btu_hcif_command_complete_evt\n");
|
||||
|
||||
hack->callback = btu_hcif_command_complete_evt_on_task;
|
||||
@@ -1649,7 +1611,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
case HCI_BLE_CREATE_BIG:
|
||||
case HCI_BLE_CREATE_BIG_TEST:
|
||||
btu_ble_create_big_cmd_status(status);
|
||||
@@ -1657,7 +1619,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c
|
||||
case HCI_BLE_TERMINATE_BIG:
|
||||
btu_ble_big_terminate_cmd_status(status);
|
||||
break;
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
case HCI_BLE_BIG_CREATE_SYNC:
|
||||
btu_ble_create_big_sync_cmd_status(status);
|
||||
@@ -1948,14 +1910,14 @@ static void btu_hcif_role_change_evt (UINT8 *p)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p)
|
||||
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
/* Process for L2CAP and SCO */
|
||||
l2c_link_process_num_completed_pkts (p);
|
||||
l2c_link_process_num_completed_pkts (p, evt_len);
|
||||
|
||||
/* Send on to SCO */
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE) && (BTM_SCO_INCLUDED == TRUE)
|
||||
btm_sco_process_num_completed_pkts (p);
|
||||
btm_sco_process_num_completed_pkts (p, evt_len);
|
||||
#endif
|
||||
}
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
@@ -2553,9 +2515,9 @@ static void btm_ble_resolve_random_addr_adv_ext(void *p_rec, void *p)
|
||||
{
|
||||
tBTM_SEC_DEV_REC *match_rec = (tBTM_SEC_DEV_REC *) p_rec;
|
||||
BD_ADDR bda;
|
||||
UINT8 *pp = (UINT8 *)p+4; //jump to the location of bd addr
|
||||
UINT8 *pp = (UINT8 *)p+2; //jump to the location of addr_type
|
||||
if (match_rec) {
|
||||
// Assign the original address to be the current report address
|
||||
UINT8_TO_STREAM(pp, match_rec->ble.ble_addr_type);
|
||||
memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
|
||||
BDADDR_TO_STREAM(pp,bda);
|
||||
}
|
||||
@@ -2569,28 +2531,47 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
|
||||
tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0};
|
||||
UINT8 num_reports = {0};
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
UINT8 *pp = p;
|
||||
UINT8 *pp;
|
||||
BOOLEAN match = FALSE;
|
||||
#endif
|
||||
//UINT8 legacy_event_type = 0;
|
||||
UINT16 evt_type = 0;
|
||||
uint8_t addr_type;
|
||||
BD_ADDR bda;
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
BOOLEAN match = FALSE;
|
||||
#endif
|
||||
UINT16 remaining;
|
||||
|
||||
if (!p) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt_len < 1) {
|
||||
HCI_TRACE_ERROR("%s, evt_len too short (%u)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(num_reports, p);
|
||||
remaining = evt_len - 1;
|
||||
|
||||
if (num_reports == 0) {
|
||||
HCI_TRACE_ERROR("%s, Invalid number reports is 0", __func__);
|
||||
}
|
||||
|
||||
/* Per-report fixed fields: evt_type(2) + addr_type(1) + bda(6) +
|
||||
* primary_phy(1) + secondary_phy(1) + sid(1) + tx_power(1) + rssi(1) +
|
||||
* per_adv_interval(2) + dir_addr_type(1) + dir_addr(6) + adv_data_len(1) = 24 */
|
||||
#define EXT_ADV_RPT_FIXED_LEN 24
|
||||
|
||||
while (num_reports--) {
|
||||
if (remaining < EXT_ADV_RPT_FIXED_LEN) {
|
||||
HCI_TRACE_ERROR("%s, remaining %u too short for report (need %u)",
|
||||
__func__, remaining, EXT_ADV_RPT_FIXED_LEN);
|
||||
return;
|
||||
}
|
||||
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
|
||||
/* Save current report start position for address resolution callback */
|
||||
pp = p;
|
||||
#endif
|
||||
STREAM_TO_UINT16(evt_type, p);
|
||||
ext_adv_report.event_type = evt_type & 0x1F;
|
||||
if(ext_adv_report.event_type & BTM_BLE_ADV_LEGACY_MASK) {
|
||||
@@ -2616,8 +2597,9 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
|
||||
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
|
||||
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
|
||||
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_adv_ext, pp);
|
||||
//the BDADDR may be updated, so read it again
|
||||
p = p - sizeof(bda);
|
||||
//the addr_type and BDADDR may be updated, so read them again
|
||||
p = p - sizeof(bda) - 1;
|
||||
STREAM_TO_UINT8(addr_type, p);
|
||||
STREAM_TO_BDADDR(bda, p);
|
||||
}
|
||||
}
|
||||
@@ -2633,6 +2615,14 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
|
||||
STREAM_TO_UINT8(ext_adv_report.dir_addr_type, p);
|
||||
STREAM_TO_BDADDR(ext_adv_report.dir_addr, p);
|
||||
STREAM_TO_UINT8(ext_adv_report.adv_data_len, p);
|
||||
remaining -= EXT_ADV_RPT_FIXED_LEN;
|
||||
|
||||
if (ext_adv_report.adv_data_len > remaining) {
|
||||
HCI_TRACE_ERROR("%s, adv_data_len %u exceeds remaining %u",
|
||||
__func__, ext_adv_report.adv_data_len, remaining);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ext_adv_report.adv_data_len) {
|
||||
ext_adv_report.adv_data = p;
|
||||
} else {
|
||||
@@ -2641,6 +2631,7 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
|
||||
|
||||
btm_ble_ext_adv_report_evt(&ext_adv_report);
|
||||
p += ext_adv_report.adv_data_len;
|
||||
remaining -= ext_adv_report.adv_data_len;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2688,6 +2679,13 @@ static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p, bool v2_evt)
|
||||
STREAM_TO_UINT8(sync_estab.rsp_slot_delay, p);
|
||||
STREAM_TO_UINT8(sync_estab.rsp_slot_spacing, p);
|
||||
}
|
||||
#else
|
||||
if (v2_evt) {
|
||||
STREAM_SKIP_UINT8(p);
|
||||
STREAM_SKIP_UINT8(p);
|
||||
STREAM_SKIP_UINT8(p);
|
||||
STREAM_SKIP_UINT8(p);
|
||||
}
|
||||
#endif // (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
|
||||
btm_ble_periodic_adv_sync_establish_evt(&sync_estab);
|
||||
@@ -2698,15 +2696,15 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len, bool v2_evt
|
||||
tBTM_PERIOD_ADV_REPORT adv_report = {0};
|
||||
/* This parameter is intended to be used in a future feature. */
|
||||
UINT8 unused = 0;
|
||||
UINT8 min_len = MIN_BLE_PERIODIC_ADV_REPORT_LEN;
|
||||
UINT8 min_len = v2_evt ? (MIN_BLE_PERIODIC_ADV_REPORT_LEN + 3) : MIN_BLE_PERIODIC_ADV_REPORT_LEN;
|
||||
|
||||
if (!p) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
if (evt_len < MIN_BLE_PERIODIC_ADV_REPORT_LEN) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params, the adv len is too short.", __func__);
|
||||
if (evt_len < min_len) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params, the adv len %d is too short.", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2718,7 +2716,11 @@ static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len, bool v2_evt
|
||||
if (v2_evt) {
|
||||
STREAM_TO_UINT16(adv_report.periodic_evt_cnt, p);
|
||||
STREAM_TO_UINT8(adv_report.subevt, p);
|
||||
min_len += 3;
|
||||
}
|
||||
#else
|
||||
if (v2_evt) {
|
||||
STREAM_SKIP_UINT16(p);
|
||||
STREAM_SKIP_UINT8(p);
|
||||
}
|
||||
#endif // (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
STREAM_TO_UINT8(adv_report.data_status, p);
|
||||
@@ -2917,6 +2919,15 @@ static void btu_ble_cis_established_evt(UINT8 *p, bool v2_evt)
|
||||
STREAM_TO_UINT24(cis_estab_evt.sdu_int_p_to_c, p);
|
||||
STREAM_TO_UINT8(cis_estab_evt.framing, p);
|
||||
}
|
||||
#else
|
||||
if (v2_evt) {
|
||||
STREAM_SKIP_UINT24(p);
|
||||
STREAM_SKIP_UINT16(p);
|
||||
STREAM_SKIP_UINT16(p);
|
||||
STREAM_SKIP_UINT24(p);
|
||||
STREAM_SKIP_UINT24(p);
|
||||
STREAM_SKIP_UINT8(p);
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_60_EN == TRUE)
|
||||
|
||||
btm_ble_cis_established_evt(&cis_estab_evt);
|
||||
@@ -2944,7 +2955,7 @@ static void btu_ble_cis_request_evt(UINT8 *p)
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
void btu_ble_create_big_cmd_status(UINT8 status)
|
||||
{
|
||||
if (status != HCI_SUCCESS) {
|
||||
@@ -2954,7 +2965,7 @@ void btu_ble_create_big_cmd_status(UINT8 status)
|
||||
}
|
||||
}
|
||||
|
||||
static void btu_ble_big_create_complete_evt(UINT8 *p)
|
||||
static void btu_ble_big_create_complete_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
HCI_TRACE_DEBUG("%s", __func__);
|
||||
tBTM_BLE_BIG_CREATE_CMPL big_cmpl = {0};
|
||||
@@ -2965,6 +2976,15 @@ static void btu_ble_big_create_complete_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: status(1) + big_handle(1) + big_sync_delay(3)
|
||||
* + transport_latency(3) + phy(1) + nse(1) + bn(1) + pto(1) + irc(1)
|
||||
* + max_pdu(2) + iso_interval(2) + num_bis(1) = 18 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 18) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=18)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(big_cmpl.status, p);
|
||||
STREAM_TO_UINT8(big_cmpl.big_handle, p);
|
||||
STREAM_TO_UINT24(big_cmpl.big_sync_delay, p);
|
||||
@@ -2978,11 +2998,14 @@ static void btu_ble_big_create_complete_evt(UINT8 *p)
|
||||
STREAM_TO_UINT16(big_cmpl.iso_interval, p);
|
||||
STREAM_TO_UINT8(num_bis, p);
|
||||
|
||||
// Validate num_bis to prevent buffer overflow
|
||||
if (num_bis > BLE_ISO_BIS_MAX_COUNT) {
|
||||
HCI_TRACE_ERROR("%s, num_bis %d exceeds BLE_ISO_BIS_MAX_COUNT %d", __func__, num_bis, BLE_ISO_BIS_MAX_COUNT);
|
||||
num_bis = BLE_ISO_BIS_MAX_COUNT;
|
||||
}
|
||||
if (num_bis > (evt_len - 18) / 2) {
|
||||
HCI_TRACE_ERROR("%s, num_bis %d exceeds evt_len %u, truncating", __func__, num_bis, evt_len);
|
||||
num_bis = (evt_len - 18) / 2;
|
||||
}
|
||||
big_cmpl.num_bis = num_bis;
|
||||
|
||||
for (uint8_t i = 0; i < num_bis; i++)
|
||||
@@ -3019,7 +3042,7 @@ static void btu_ble_big_terminate_complete_evt(UINT8 *p)
|
||||
|
||||
btm_ble_big_terminate_cmpl_evt(&big_term);
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
void btu_ble_create_big_sync_cmd_status(UINT8 status)
|
||||
@@ -3031,7 +3054,7 @@ void btu_ble_create_big_sync_cmd_status(UINT8 status)
|
||||
}
|
||||
}
|
||||
|
||||
static void btu_ble_big_sync_establish_evt(UINT8 *p)
|
||||
static void btu_ble_big_sync_establish_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_BIG_SYNC_ESTAB_CMPL big_estb = {0};
|
||||
UINT8 num_bis;
|
||||
@@ -3041,6 +3064,15 @@ static void btu_ble_big_sync_establish_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: status(1) + big_handle(1) + transport_latency_big(3)
|
||||
* + nse(1) + bn(1) + pto(1) + irc(1) + max_pdu(2) + iso_interval(2)
|
||||
* + num_bis(1) = 14 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 14) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=14)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(big_estb.status, p);
|
||||
STREAM_TO_UINT8(big_estb.big_handle, p);
|
||||
STREAM_TO_UINT24(big_estb.transport_latency_big, p);
|
||||
@@ -3052,11 +3084,14 @@ static void btu_ble_big_sync_establish_evt(UINT8 *p)
|
||||
STREAM_TO_UINT16(big_estb.iso_interval, p);
|
||||
STREAM_TO_UINT8(num_bis, p);
|
||||
|
||||
// Validate num_bis to prevent buffer overflow
|
||||
if (num_bis > BLE_ISO_BIS_MAX_COUNT) {
|
||||
HCI_TRACE_ERROR("%s, num_bis %d exceeds BLE_ISO_BIS_MAX_COUNT %d", __func__, num_bis, BLE_ISO_BIS_MAX_COUNT);
|
||||
num_bis = BLE_ISO_BIS_MAX_COUNT;
|
||||
}
|
||||
if (num_bis > (evt_len - 14) / 2) {
|
||||
HCI_TRACE_ERROR("%s, num_bis %d exceeds evt_len %u, truncating", __func__, num_bis, evt_len);
|
||||
num_bis = (evt_len - 14) / 2;
|
||||
}
|
||||
big_estb.num_bis = num_bis;
|
||||
|
||||
for (uint8_t i = 0; i < num_bis; i++)
|
||||
@@ -3112,7 +3147,7 @@ static void btu_ble_biginfo_adv_report_evt(UINT8 *p)
|
||||
|
||||
#if (BLE_FEAT_CTE_EN == TRUE)
|
||||
#if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
static void btu_ble_cte_connless_iq_report_evt(UINT8 *p)
|
||||
static void btu_ble_cte_connless_iq_report_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_CTE_CONNLESS_IQ_REPORT_EVT connless_iq_rpt = {0};
|
||||
UINT8 sample_count;
|
||||
@@ -3122,6 +3157,15 @@ static void btu_ble_cte_connless_iq_report_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: sync_handle(2) + channel_idx(1) + rssi(2)
|
||||
* + rssi_ant_id(1) + cte_type(1) + slot_dur(1) + pkt_status(1)
|
||||
* + periodic_evt_counter(2) + sample_count(1) = 12 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 12) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=12)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT16(connless_iq_rpt.sync_handle, p);
|
||||
STREAM_TO_UINT8(connless_iq_rpt.channel_idx, p);
|
||||
STREAM_TO_UINT16(connless_iq_rpt.rssi, p);
|
||||
@@ -3132,11 +3176,14 @@ static void btu_ble_cte_connless_iq_report_evt(UINT8 *p)
|
||||
STREAM_TO_UINT16(connless_iq_rpt.periodic_evt_counter, p);
|
||||
STREAM_TO_UINT8(sample_count, p);
|
||||
|
||||
// Validate sample_count to prevent buffer overflow
|
||||
if (sample_count > BTM_BLE_CTE_MAX_SAMPLE_COUNT) {
|
||||
HCI_TRACE_ERROR("%s, sample_count %d exceeds maximum %d", __func__, sample_count, BTM_BLE_CTE_MAX_SAMPLE_COUNT);
|
||||
sample_count = BTM_BLE_CTE_MAX_SAMPLE_COUNT;
|
||||
}
|
||||
if (sample_count > (evt_len - 12) / 2) {
|
||||
HCI_TRACE_ERROR("%s, sample_count %d exceeds evt_len %u, truncating", __func__, sample_count, evt_len);
|
||||
sample_count = (evt_len - 12) / 2;
|
||||
}
|
||||
connless_iq_rpt.sample_count = sample_count;
|
||||
|
||||
for (uint8_t i = 0; i < sample_count; i++)
|
||||
@@ -3154,7 +3201,7 @@ static void btu_ble_cte_connless_iq_report_evt(UINT8 *p)
|
||||
#endif // #if (BLE_FEAT_CTE_CONNECTIONLESS_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_CTE_CONNECTION_EN == TRUE)
|
||||
static void btu_ble_cte_conn_iq_report_evt(UINT8 *p)
|
||||
static void btu_ble_cte_conn_iq_report_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_CTE_CONN_IQ_REPORT_EVT conn_iq_rpt = {0};
|
||||
UINT8 sample_count;
|
||||
@@ -3164,6 +3211,15 @@ static void btu_ble_cte_conn_iq_report_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: conn_handle(2) + rx_phy(1) + data_channel_idx(1)
|
||||
* + rssi(2) + rssi_ant_id(1) + cte_type(1) + slot_dur(1) + pkt_status(1)
|
||||
* + conn_evt_counter(2) + sample_count(1) = 13 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 13) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=13)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT16(conn_iq_rpt.conn_handle, p);
|
||||
STREAM_TO_UINT8(conn_iq_rpt.rx_phy, p);
|
||||
STREAM_TO_UINT8(conn_iq_rpt.data_channel_idx, p);
|
||||
@@ -3175,11 +3231,14 @@ static void btu_ble_cte_conn_iq_report_evt(UINT8 *p)
|
||||
STREAM_TO_UINT16(conn_iq_rpt.conn_evt_counter, p);
|
||||
STREAM_TO_UINT8(sample_count, p);
|
||||
|
||||
// Validate sample_count to prevent buffer overflow
|
||||
if (sample_count > BTM_BLE_CTE_MAX_SAMPLE_COUNT) {
|
||||
HCI_TRACE_ERROR("%s, sample_count %d exceeds maximum %d", __func__, sample_count, BTM_BLE_CTE_MAX_SAMPLE_COUNT);
|
||||
sample_count = BTM_BLE_CTE_MAX_SAMPLE_COUNT;
|
||||
}
|
||||
if (sample_count > (evt_len - 13) / 2) {
|
||||
HCI_TRACE_ERROR("%s, sample_count %d exceeds evt_len %u, truncating", __func__, sample_count, evt_len);
|
||||
sample_count = (evt_len - 13) / 2;
|
||||
}
|
||||
conn_iq_rpt.sample_count = sample_count;
|
||||
|
||||
for (uint8_t i = 0; i < sample_count; i++)
|
||||
@@ -3285,7 +3344,7 @@ static void btu_ble_pa_subevt_data_request_evt(UINT8 *p)
|
||||
btm_ble_pa_subevt_data_req_evt(&pa_subevt_req_evt);
|
||||
}
|
||||
|
||||
static void btu_ble_pa_response_report_evt(UINT8 *p)
|
||||
static void btu_ble_pa_response_report_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_PA_RSP_REPORT_EVT pa_rsp_rpt_evt = {0};
|
||||
if (!p) {
|
||||
@@ -3293,33 +3352,58 @@ static void btu_ble_pa_response_report_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: adv_handle(1) + subevt(1) + tx_status(1) + num_rsp(1) = 4 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 4) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=4)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.adv_handle, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.subevt, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.tx_status, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.num_rsp, p);
|
||||
|
||||
// num_rsp is UINT8, range 0x00 to 0xFF (0 to 255), no need to validate
|
||||
UINT8 remaining = evt_len - 4;
|
||||
|
||||
if (pa_rsp_rpt_evt.num_rsp) {
|
||||
pa_rsp_rpt_evt.rsp_data_info = osi_malloc(pa_rsp_rpt_evt.num_rsp * sizeof(tBTM_BLE_PA_RSP_DATA_INFO));
|
||||
if (pa_rsp_rpt_evt.rsp_data_info)
|
||||
{
|
||||
for (UINT8 i = 0; i < pa_rsp_rpt_evt.num_rsp; i++)
|
||||
{
|
||||
/* Per-response fixed: tx_power(1)+rssi(1)+cte_type(1)+rsp_slot(1)+data_status(1)+data_len(1) = 6 */
|
||||
if (remaining < 6) {
|
||||
HCI_TRACE_ERROR("%s, remaining %u too short for response %d", __func__, remaining, i);
|
||||
pa_rsp_rpt_evt.num_rsp = i;
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].tx_power, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].rssi, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].cte_type, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].rsp_slot, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].data_status, p);
|
||||
STREAM_TO_UINT8(pa_rsp_rpt_evt.rsp_data_info[i].data_len, p);
|
||||
// data_len is UINT8, range 0x00 to 0xFF (0 to 255), no need to validate
|
||||
remaining -= 6;
|
||||
if (pa_rsp_rpt_evt.rsp_data_info[i].data_len > remaining) {
|
||||
HCI_TRACE_ERROR("%s, data_len %d exceeds remaining %u at index %d",
|
||||
__func__, pa_rsp_rpt_evt.rsp_data_info[i].data_len, remaining, i);
|
||||
pa_rsp_rpt_evt.rsp_data_info[i].data_len = 0;
|
||||
pa_rsp_rpt_evt.rsp_data_info[i].data = NULL;
|
||||
pa_rsp_rpt_evt.num_rsp = i + 1;
|
||||
break;
|
||||
}
|
||||
if (pa_rsp_rpt_evt.rsp_data_info[i].data_len) {
|
||||
pa_rsp_rpt_evt.rsp_data_info[i].data = osi_malloc(pa_rsp_rpt_evt.rsp_data_info[i].data_len);
|
||||
if (pa_rsp_rpt_evt.rsp_data_info[i].data) {
|
||||
STREAM_TO_ARRAY(pa_rsp_rpt_evt.rsp_data_info[i].data, p, pa_rsp_rpt_evt.rsp_data_info[i].data_len);
|
||||
} else {
|
||||
HCI_TRACE_ERROR("%s, no enough memory for data_len %d at index %d", __func__, pa_rsp_rpt_evt.rsp_data_info[i].data_len, i);
|
||||
p += pa_rsp_rpt_evt.rsp_data_info[i].data_len;
|
||||
remaining -= pa_rsp_rpt_evt.rsp_data_info[i].data_len;
|
||||
pa_rsp_rpt_evt.rsp_data_info[i].data_len = 0;
|
||||
}
|
||||
remaining -= pa_rsp_rpt_evt.rsp_data_info[i].data_len;
|
||||
} else {
|
||||
pa_rsp_rpt_evt.rsp_data_info[i].data = NULL;
|
||||
}
|
||||
@@ -3468,13 +3552,25 @@ static void btu_ble_cs_proc_enable_cmpl_evt(UINT8 *p)
|
||||
btm_ble_cs_proc_enable_cmpl_evt(&proc_en);
|
||||
}
|
||||
|
||||
static void btu_ble_cs_subevt_result_evt(UINT8 *p)
|
||||
static void btu_ble_cs_subevt_result_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_CS_SUBEVT_RESULT_CMPL_EVT subevt_result = {0};
|
||||
if (!p) {
|
||||
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: conn_handle(2) + config_id(1) +
|
||||
* start_acl_conn_event_counter(2) + procedure_counter(2) +
|
||||
* frequency_compensation(2) + reference_power_level(1) +
|
||||
* procedure_done_status(1) + subevent_done_status(1) + abort_reason(1) +
|
||||
* num_ant_paths(1) + num_steps_reported(1) = 15 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 15) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=15)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT16(subevt_result.conn_handle, p);
|
||||
STREAM_TO_UINT8(subevt_result.config_id, p);
|
||||
STREAM_TO_UINT16(subevt_result.start_acl_conn_event_counter, p);
|
||||
@@ -3488,27 +3584,49 @@ static void btu_ble_cs_subevt_result_evt(UINT8 *p)
|
||||
UINT8 num_steps_reported;
|
||||
STREAM_TO_UINT8(num_steps_reported, p);
|
||||
|
||||
// Validate num_steps_reported per BLE spec: Range 0x00 to 0xA0 (0 to 160)
|
||||
if (num_steps_reported > BTM_BLE_CS_MAX_STEPS_REPORTED) {
|
||||
HCI_TRACE_ERROR("%s, num_steps_reported %d exceeds maximum %d", __func__, num_steps_reported, BTM_BLE_CS_MAX_STEPS_REPORTED);
|
||||
num_steps_reported = BTM_BLE_CS_MAX_STEPS_REPORTED;
|
||||
}
|
||||
subevt_result.num_steps_reported = num_steps_reported;
|
||||
|
||||
subevt_result.step_info = osi_malloc(subevt_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO));
|
||||
if (subevt_result.step_info) {
|
||||
UINT8 remaining = evt_len - 15;
|
||||
subevt_result.step_info = (subevt_result.num_steps_reported > 0)
|
||||
? osi_malloc(subevt_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO))
|
||||
: NULL;
|
||||
if (subevt_result.step_info || subevt_result.num_steps_reported == 0) {
|
||||
for (uint8_t i = 0; i < subevt_result.num_steps_reported; i++)
|
||||
{
|
||||
/* Per-step fixed: step_mode(1) + step_channel(1) + step_data_len(1) = 3 */
|
||||
if (remaining < 3) {
|
||||
HCI_TRACE_ERROR("%s, remaining %u too short for step %d", __func__, remaining, i);
|
||||
subevt_result.num_steps_reported = i;
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT8(subevt_result.step_info[i].step_mode, p);
|
||||
STREAM_TO_UINT8(subevt_result.step_info[i].step_channel, p);
|
||||
STREAM_TO_UINT8(subevt_result.step_info[i].step_data_len, p);
|
||||
// step_data_len is UINT8, range 0x00 to 0xFF (0 to 255), no need to validate
|
||||
remaining -= 3;
|
||||
if (subevt_result.step_info[i].step_data_len > remaining) {
|
||||
HCI_TRACE_ERROR("%s, step_data_len %d exceeds remaining %u at step %d",
|
||||
__func__, subevt_result.step_info[i].step_data_len, remaining, i);
|
||||
subevt_result.step_info[i].step_data_len = 0;
|
||||
subevt_result.step_info[i].data = NULL;
|
||||
subevt_result.num_steps_reported = i + 1;
|
||||
break;
|
||||
}
|
||||
subevt_result.step_info[i].data = osi_malloc(subevt_result.step_info[i].step_data_len);
|
||||
if (subevt_result.step_info[i].data) {
|
||||
STREAM_TO_ARRAY(subevt_result.step_info[i].data, p, subevt_result.step_info[i].step_data_len);
|
||||
} else if (subevt_result.step_info[i].step_data_len) {
|
||||
HCI_TRACE_ERROR("%s, no memory.", __func__);
|
||||
p += subevt_result.step_info[i].step_data_len;
|
||||
subevt_result.step_info[i].step_data_len = 0;
|
||||
subevt_result.step_info[i].data = NULL;
|
||||
subevt_result.num_steps_reported = i + 1;
|
||||
break;
|
||||
}
|
||||
remaining -= subevt_result.step_info[i].step_data_len;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3527,7 +3645,7 @@ static void btu_ble_cs_subevt_result_evt(UINT8 *p)
|
||||
|
||||
}
|
||||
|
||||
static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p)
|
||||
static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
tBTM_BLE_CS_SUBEVT_RESULT_CONTINUE_EVT subevt_continue_result = {0};
|
||||
|
||||
@@ -3536,6 +3654,15 @@ static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fixed fields: conn_handle(2) + config_id(1) + proc_done_status(1)
|
||||
* + subevt_done_status(1) + abort_reason(1) + num_ant_paths(1)
|
||||
* + num_steps_reported(1) = 8 bytes
|
||||
* (subevent_code already subtracted from evt_len by caller) */
|
||||
if (evt_len < 8) {
|
||||
HCI_TRACE_ERROR("%s, evt too short (len=%u, need>=8)", __func__, evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT16(subevt_continue_result.conn_handle, p);
|
||||
STREAM_TO_UINT8(subevt_continue_result.config_id, p);
|
||||
STREAM_TO_UINT8(subevt_continue_result.proc_done_status, p);
|
||||
@@ -3545,27 +3672,50 @@ static void btu_ble_cs_subevt_result_continue_evt(UINT8 *p)
|
||||
UINT8 num_steps_reported;
|
||||
STREAM_TO_UINT8(num_steps_reported, p);
|
||||
|
||||
// Validate num_steps_reported per BLE spec: Range 0x00 to 0xA0 (0 to 160)
|
||||
if (num_steps_reported > BTM_BLE_CS_MAX_STEPS_REPORTED) {
|
||||
HCI_TRACE_ERROR("%s, num_steps_reported %d exceeds maximum %d", __func__, num_steps_reported, BTM_BLE_CS_MAX_STEPS_REPORTED);
|
||||
num_steps_reported = BTM_BLE_CS_MAX_STEPS_REPORTED;
|
||||
}
|
||||
subevt_continue_result.num_steps_reported = num_steps_reported;
|
||||
|
||||
subevt_continue_result.step_info = osi_malloc(subevt_continue_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO));
|
||||
if (subevt_continue_result.step_info) {
|
||||
UINT8 remaining = evt_len - 8;
|
||||
subevt_continue_result.step_info = (subevt_continue_result.num_steps_reported > 0)
|
||||
? osi_malloc(subevt_continue_result.num_steps_reported * sizeof(tBTM_BLE_CS_STEP_INFO))
|
||||
: NULL;
|
||||
if (subevt_continue_result.step_info || subevt_continue_result.num_steps_reported == 0) {
|
||||
for (uint8_t i = 0; i < subevt_continue_result.num_steps_reported; i++) {
|
||||
if (remaining < 3) {
|
||||
HCI_TRACE_ERROR("%s, remaining %u too short for step %d", __func__, remaining, i);
|
||||
subevt_continue_result.num_steps_reported = i;
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_mode, p);
|
||||
STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_channel, p);
|
||||
STREAM_TO_UINT8(subevt_continue_result.step_info[i].step_data_len, p);
|
||||
// step_data_len is UINT8, range 0x00 to 0xFF (0 to 255), no need to validate
|
||||
remaining -= 3;
|
||||
if (subevt_continue_result.step_info[i].step_data_len > remaining) {
|
||||
HCI_TRACE_ERROR("%s, step_data_len %d exceeds remaining %u at step %d",
|
||||
__func__, subevt_continue_result.step_info[i].step_data_len, remaining, i);
|
||||
subevt_continue_result.step_info[i].step_data_len = 0;
|
||||
subevt_continue_result.step_info[i].data = NULL;
|
||||
subevt_continue_result.num_steps_reported = i + 1;
|
||||
break;
|
||||
}
|
||||
subevt_continue_result.step_info[i].data = osi_malloc(subevt_continue_result.step_info[i].step_data_len);
|
||||
if (subevt_continue_result.step_info[i].data) {
|
||||
STREAM_TO_ARRAY(subevt_continue_result.step_info[i].data, p, subevt_continue_result.step_info[i].step_data_len);
|
||||
} else if (subevt_continue_result.step_info[i].step_data_len) {
|
||||
HCI_TRACE_ERROR("%s, no memory.", __func__);
|
||||
p += subevt_continue_result.step_info[i].step_data_len;
|
||||
subevt_continue_result.step_info[i].step_data_len = 0;
|
||||
subevt_continue_result.step_info[i].data = NULL;
|
||||
subevt_continue_result.num_steps_reported = i + 1;
|
||||
break;
|
||||
}
|
||||
remaining -= subevt_continue_result.step_info[i].step_data_len;
|
||||
}
|
||||
} else {
|
||||
HCI_TRACE_ERROR("%s, no memory for step_info.", __func__);
|
||||
}
|
||||
|
||||
btm_ble_cs_subevt_continue_result_evt(&subevt_continue_result);
|
||||
|
||||
@@ -449,7 +449,17 @@ void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec)
|
||||
osi_mutex_lock(&btu_general_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) {
|
||||
alarm = osi_alarm_new("btu_gen", btu_general_alarm_cb, (void *)p_tle, 0);
|
||||
hash_map_set(btu_general_alarm_hash_map, p_tle, alarm);
|
||||
if (alarm == NULL) {
|
||||
HCI_TRACE_ERROR("%s Unable to create new alarm", __func__);
|
||||
osi_mutex_unlock(&btu_general_alarm_lock);
|
||||
return;
|
||||
}
|
||||
if (!hash_map_set(btu_general_alarm_hash_map, p_tle, alarm)) {
|
||||
HCI_TRACE_ERROR("%s Unable to set alarm in map", __func__);
|
||||
osi_alarm_free(alarm);
|
||||
osi_mutex_unlock(&btu_general_alarm_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
osi_mutex_unlock(&btu_general_alarm_lock);
|
||||
|
||||
@@ -564,7 +574,17 @@ void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ti
|
||||
osi_mutex_lock(&btu_l2cap_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
|
||||
alarm = osi_alarm_new("btu_l2cap", btu_l2cap_alarm_cb, (void *)p_tle, 0);
|
||||
hash_map_set(btu_l2cap_alarm_hash_map, p_tle, (void *)alarm);
|
||||
if (alarm == NULL) {
|
||||
HCI_TRACE_ERROR("%s Unable to create alarm", __func__);
|
||||
osi_mutex_unlock(&btu_l2cap_alarm_lock);
|
||||
return;
|
||||
}
|
||||
if (!hash_map_set(btu_l2cap_alarm_hash_map, p_tle, (void *)alarm)) {
|
||||
HCI_TRACE_ERROR("%s Unable to set alarm in map", __func__);
|
||||
osi_alarm_free(alarm);
|
||||
osi_mutex_unlock(&btu_l2cap_alarm_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
osi_mutex_unlock(&btu_l2cap_alarm_lock);
|
||||
|
||||
@@ -650,7 +670,17 @@ void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_
|
||||
osi_mutex_lock(&btu_oneshot_alarm_lock, OSI_MUTEX_MAX_TIMEOUT);
|
||||
if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) {
|
||||
alarm = osi_alarm_new("btu_oneshot", btu_oneshot_alarm_cb, (void *)p_tle, 0);
|
||||
hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm);
|
||||
if (alarm == NULL) {
|
||||
HCI_TRACE_ERROR("%s Unable to create new alarm", __func__);
|
||||
osi_mutex_unlock(&btu_oneshot_alarm_lock);
|
||||
return;
|
||||
}
|
||||
if (!hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm)) {
|
||||
HCI_TRACE_ERROR("%s Unable to set alarm in map", __func__);
|
||||
osi_alarm_free(alarm);
|
||||
osi_mutex_unlock(&btu_oneshot_alarm_lock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
osi_mutex_unlock(&btu_oneshot_alarm_lock);
|
||||
|
||||
|
||||
@@ -315,6 +315,9 @@ UINT8 gap_proc_write_req( tGATTS_REQ_TYPE type, tGATT_WRITE_REQ *p_data)
|
||||
switch (p_db_attr->uuid) {
|
||||
#if (GATTS_DEVICE_NAME_WRITABLE == TRUE)
|
||||
case GATT_UUID_GAP_DEVICE_NAME: {
|
||||
if (p_data->len > BD_NAME_LEN) {
|
||||
return GATT_INVALID_ATTR_LEN;
|
||||
}
|
||||
UINT8 *p_val = p_data->value;
|
||||
p_val[p_data->len] = '\0';
|
||||
BTM_SetLocalDeviceName((char *)p_val, BT_DEVICE_TYPE_BLE);
|
||||
@@ -775,6 +778,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
|
||||
{
|
||||
tGAP_CLCB *p_clcb;
|
||||
BOOLEAN started = FALSE;
|
||||
BOOLEAN is_new_clcb = FALSE;
|
||||
|
||||
if (p_cback == NULL && uuid != GATT_UUID_GAP_PREF_CONN_PARAM) {
|
||||
return (started);
|
||||
@@ -785,6 +789,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
|
||||
GAP_TRACE_ERROR("gap_ble_accept_cl_operation max connection reached");
|
||||
return started;
|
||||
}
|
||||
is_new_clcb = TRUE;
|
||||
}
|
||||
|
||||
GAP_TRACE_EVENT ("%s() - BDA: %08x%04x cl_op_uuid: 0x%04x",
|
||||
@@ -798,11 +803,25 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
|
||||
|
||||
/* hold the link here */
|
||||
if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE, FALSE, FALSE, 0xFF, 0xFF)) {
|
||||
if (is_new_clcb) {
|
||||
gap_ble_dealloc_clcb(p_clcb);
|
||||
}
|
||||
return started;
|
||||
}
|
||||
|
||||
/* enqueue the request */
|
||||
gap_ble_enqueue_request(p_clcb, uuid, p_cback);
|
||||
if (gap_ble_enqueue_request(p_clcb, uuid, p_cback) == FALSE) {
|
||||
GAP_TRACE_ERROR("gap_ble_accept_cl_operation enqueue request failed");
|
||||
if (is_new_clcb) {
|
||||
if (p_clcb->connected) {
|
||||
GATT_Disconnect(p_clcb->conn_id);
|
||||
} else {
|
||||
GATT_CancelConnect(gap_cb.gatt_if, p_clcb->bda, TRUE);
|
||||
}
|
||||
gap_ble_dealloc_clcb(p_clcb);
|
||||
}
|
||||
return started;
|
||||
}
|
||||
|
||||
if (p_clcb->connected && p_clcb->cl_op_uuid == 0) {
|
||||
started = gap_ble_send_cl_read_request(p_clcb);
|
||||
|
||||
@@ -166,6 +166,11 @@ BT_HDR *attp_build_read_by_type_value_cmd (UINT16 payload_size, tGATT_FIND_TYPE_
|
||||
UINT8 *p;
|
||||
UINT16 len = p_value_type->value_len;
|
||||
|
||||
if (payload_size < GATT_DEF_BLE_MTU_SIZE) {
|
||||
// never build packet smaller than default MTU size
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((p_buf = (BT_HDR *)osi_malloc((UINT16)(sizeof(BT_HDR) + payload_size + L2CAP_MIN_OFFSET))) != NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
|
||||
@@ -1029,6 +1029,12 @@ tGATT_STATUS GATTC_Read (UINT16 conn_id, tGATT_READ_TYPE type, tGATT_READ_PARAM
|
||||
p_clcb->s_handle = 0;
|
||||
/* copy multiple handles in CB */
|
||||
p_read_multi = (tGATT_READ_MULTI *)osi_malloc(sizeof(tGATT_READ_MULTI));
|
||||
if (p_read_multi == NULL) {
|
||||
GATT_TRACE_ERROR("GATTC_Read no resources for multiple read");
|
||||
status = GATT_NO_RESOURCES;
|
||||
gatt_clcb_dealloc(p_clcb);
|
||||
return status;
|
||||
}
|
||||
p_clcb->p_attr_buf = (UINT8 *)p_read_multi;
|
||||
memcpy (p_read_multi, &p_read->read_multiple, sizeof(tGATT_READ_MULTI));
|
||||
case GATT_READ_BY_HANDLE:
|
||||
@@ -1382,7 +1388,8 @@ void GATT_Deregister (tGATT_IF gatt_if)
|
||||
(p_clcb->p_tcb->tcb_idx == p_tcb->tcb_idx)) {
|
||||
btu_stop_timer(&p_clcb->rsp_timer_ent);
|
||||
gatt_clcb_dealloc (p_clcb);
|
||||
break;
|
||||
// Removed break to ensure all CLCBs are cleaned up
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1394,6 +1401,10 @@ void GATT_Deregister (tGATT_IF gatt_if)
|
||||
memset (p_reg, 0, sizeof(tGATT_REG));
|
||||
}
|
||||
|
||||
void gatt_start_if_conn_cb(UINT8 tcb_idx, tBT_TRANSPORT transport, BD_ADDR bda)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1412,21 +1423,19 @@ void GATT_StartIf (tGATT_IF gatt_if)
|
||||
{
|
||||
tGATT_REG *p_reg;
|
||||
tGATT_TCB *p_tcb;
|
||||
BD_ADDR bda;
|
||||
UINT8 start_idx, found_idx;
|
||||
UINT16 conn_id;
|
||||
tGATT_TRANSPORT transport ;
|
||||
list_node_t *p_node = NULL;
|
||||
|
||||
GATT_TRACE_API ("GATT_StartIf gatt_if=%d", gatt_if);
|
||||
if ((p_reg = gatt_get_regcb(gatt_if)) != NULL) {
|
||||
start_idx = 0;
|
||||
while (gatt_find_the_connected_bda(start_idx, bda, &found_idx, &transport)) {
|
||||
p_tcb = gatt_find_tcb_by_addr(bda, transport);
|
||||
if (p_reg->app_cb.p_conn_cb && p_tcb) {
|
||||
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
|
||||
(*p_reg->app_cb.p_conn_cb)(gatt_if, bda, conn_id, TRUE, 0, transport);
|
||||
for (p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb->in_use && p_tcb->ch_state == GATT_CH_OPEN) {
|
||||
if (p_reg->app_cb.p_conn_cb && p_tcb) {
|
||||
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
|
||||
(*p_reg->app_cb.p_conn_cb)(gatt_if, p_tcb->peer_bda, conn_id, TRUE, 0, p_tcb->transport);
|
||||
}
|
||||
}
|
||||
start_idx = ++found_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1593,11 +1602,10 @@ tGATT_STATUS GATT_Disconnect (UINT16 conn_id)
|
||||
*******************************************************************************/
|
||||
tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
|
||||
{
|
||||
UINT8 start_idx, found_idx;
|
||||
BOOLEAN srv_chg_ind_pending = FALSE;
|
||||
tGATT_TCB *p_tcb;
|
||||
tBT_TRANSPORT transport;
|
||||
tGATT_STATUS status = GATT_NOT_FOUND;
|
||||
list_node_t *p_node = NULL;
|
||||
|
||||
if (gatt_cb.srv_chg_mode == GATTS_SEND_SERVICE_CHANGE_AUTO) {
|
||||
status = GATT_WRONG_STATE;
|
||||
@@ -1608,19 +1616,17 @@ tGATT_STATUS GATT_SendServiceChangeIndication (BD_ADDR bd_addr)
|
||||
if(bd_addr) {
|
||||
status = gatt_send_srv_chg_ind(bd_addr);
|
||||
} else {
|
||||
start_idx = 0;
|
||||
BD_ADDR addr;
|
||||
while (gatt_find_the_connected_bda(start_idx, addr, &found_idx, &transport)) {
|
||||
p_tcb = gatt_get_tcb_by_idx(found_idx);
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
|
||||
if (!srv_chg_ind_pending) {
|
||||
status = gatt_send_srv_chg_ind(addr);
|
||||
} else {
|
||||
status = GATT_BUSY;
|
||||
GATT_TRACE_DEBUG("discard srv chg - already has one in the queue");
|
||||
for (p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb->in_use && p_tcb->ch_state == GATT_CH_OPEN) {
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
if (!srv_chg_ind_pending) {
|
||||
status = gatt_send_srv_chg_ind(p_tcb->peer_bda);
|
||||
} else {
|
||||
status = GATT_BUSY;
|
||||
GATT_TRACE_DEBUG("discard srv chg - already has one in the queue");
|
||||
}
|
||||
}
|
||||
start_idx = ++found_idx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,8 @@ static BOOLEAN gatt_sign_data (tGATT_CLCB *p_clcb)
|
||||
}
|
||||
|
||||
osi_free(p_data);
|
||||
} else {
|
||||
gatt_end_operation(p_clcb, GATT_NO_RESOURCES, NULL);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -449,7 +449,7 @@ void gatt_process_find_type_value_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UIN
|
||||
void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
|
||||
UINT16 len, UINT8 *p_data)
|
||||
{
|
||||
tGATT_DISC_RES result;
|
||||
tGATT_DISC_RES result = {0};
|
||||
UINT8 *p = p_data, uuid_len = 0, type;
|
||||
|
||||
UNUSED(p_tcb);
|
||||
@@ -472,6 +472,10 @@ void gatt_process_read_info_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_c
|
||||
uuid_len = LEN_UUID_16;
|
||||
} else if (type == GATT_INFO_TYPE_PAIR_128) {
|
||||
uuid_len = LEN_UUID_128;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("invalid Info Response PDU format: %d", type);
|
||||
gatt_end_operation(p_clcb, GATT_INVALID_PDU, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
while (len >= uuid_len + 2) {
|
||||
@@ -796,7 +800,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
|
||||
if ((value_len > (p_tcb->payload_size - 2)) || (value_len > (len - 1)) ) {
|
||||
/* this is an error case that server's response containing a value length which is larger than MTU-2
|
||||
or value_len > message total length -1 */
|
||||
GATT_TRACE_ERROR("gatt_process_read_by_type_rsp: Discard response op_code=%d vale_len=%d > (MTU-2=%d or msg_len-1=%d)",
|
||||
GATT_TRACE_ERROR("gatt_process_read_by_type_rsp: Discard response op_code=%d value_len=%d > (MTU-2=%d or msg_len-1=%d)",
|
||||
op_code, value_len, (p_tcb->payload_size - 2), (len - 1));
|
||||
gatt_end_operation(p_clcb, GATT_ERROR, NULL);
|
||||
return;
|
||||
@@ -884,7 +888,8 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
|
||||
}
|
||||
/* read by type */
|
||||
else if (p_clcb->operation == GATTC_OPTYPE_READ && p_clcb->op_subtype == GATT_READ_BY_TYPE) {
|
||||
p_clcb->counter = len - 2;
|
||||
/* value_len is the length of current record's value; use it to avoid overread when multiple records present */
|
||||
p_clcb->counter = value_len;
|
||||
p_clcb->s_handle = handle;
|
||||
if ( p_clcb->counter == (p_clcb->p_tcb->payload_size - 4)) {
|
||||
p_clcb->op_subtype = GATT_READ_BY_HANDLE;
|
||||
@@ -916,7 +921,7 @@ void gatt_process_read_by_type_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8
|
||||
|
||||
/* UUID not matching */
|
||||
if (!gatt_uuid_compare(record_value.dclr_value.char_uuid, p_clcb->uuid)) {
|
||||
len -= (value_len + 2);
|
||||
len -= (value_len + handle_len);
|
||||
continue; /* skip the result, and look for next one */
|
||||
} else if (p_clcb->operation == GATTC_OPTYPE_READ)
|
||||
/* UUID match for read characteristic value */
|
||||
@@ -1000,7 +1005,7 @@ void gatt_process_read_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op_code,
|
||||
gatt_end_operation(p_clcb, GATT_SUCCESS, (void *)p_clcb->p_attr_buf);
|
||||
}
|
||||
} else { /* exception, should not happen */
|
||||
GATT_TRACE_ERROR("attr offset = %d p_attr_buf = %p ", offset, p_clcb->p_attr_buf);
|
||||
GATT_TRACE_ERROR("attr offset = %d p_attr_buf = %p ", offset, p_clcb->p_attr_buf ? p_clcb->p_attr_buf:0);
|
||||
gatt_end_operation(p_clcb, GATT_NO_RESOURCES, (void *)p_clcb->p_attr_buf);
|
||||
}
|
||||
}
|
||||
@@ -1141,9 +1146,11 @@ BOOLEAN gatt_cl_send_next_cmd_inq(tGATT_TCB *p_tcb)
|
||||
}
|
||||
} else {
|
||||
GATT_TRACE_ERROR("gatt_cl_send_next_cmd_inq: L2CAP sent error");
|
||||
|
||||
/* attp_send_msg_to_l2cap() already freed p_cmd->p_cmd on failure */
|
||||
p_cmd->p_cmd = NULL;
|
||||
memset(p_cmd, 0, sizeof(tGATT_CMD_Q));
|
||||
p_tcb->pending_cl_req ++;
|
||||
p_tcb->pending_cl_req %= GATT_CL_MAX_LCB;
|
||||
p_cmd = &p_tcb->cl_cmd_q[p_tcb->pending_cl_req];
|
||||
}
|
||||
|
||||
|
||||
@@ -363,6 +363,7 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
|
||||
|
||||
if (p_attr->handle >= s_handle && gatt_uuid_compare(type, attr_uuid)) {
|
||||
if (*p_len <= 2) {
|
||||
*p_cur_handle = p_attr->handle;
|
||||
status = GATT_NO_RESOURCES;
|
||||
break;
|
||||
}
|
||||
@@ -375,15 +376,19 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
|
||||
|
||||
need_rsp = TRUE;
|
||||
status = gatts_send_app_read_request(p_tcb, op_code, p_attr->handle, 0, trans_id, need_rsp);
|
||||
|
||||
if (status != GATT_PENDING) {
|
||||
*p_cur_handle = p_attr->handle;
|
||||
}
|
||||
/* one callback at a time */
|
||||
break;
|
||||
} else if (status == GATT_SUCCESS || status == GATT_STACK_RSP) {
|
||||
if (status == GATT_STACK_RSP){
|
||||
need_rsp = FALSE;
|
||||
status = gatts_send_app_read_request(p_tcb, op_code, p_attr->handle, 0, trans_id, need_rsp);
|
||||
if(status == GATT_BUSY)
|
||||
if (status != GATT_STACK_RSP) {
|
||||
*p_cur_handle = p_attr->handle;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!have_send_request){
|
||||
have_send_request = true;
|
||||
@@ -400,6 +405,7 @@ tGATT_STATUS gatts_db_read_attr_value_by_type (tGATT_TCB *p_tcb,
|
||||
*p_len -= (len + 2);
|
||||
} else {
|
||||
GATT_TRACE_WARNING("format mismatch");
|
||||
*p_cur_handle = p_attr->handle;
|
||||
status = GATT_NO_RESOURCES;
|
||||
break;
|
||||
}
|
||||
@@ -546,6 +552,7 @@ UINT16 gatts_add_characteristic (tGATT_SVC_DB *p_db, tGATT_PERM perm,
|
||||
|
||||
if (attr_val != NULL) {
|
||||
if (!copy_extra_byte_in_db(p_db, (void **)&p_char_val->p_value, sizeof(tGATT_ATTR_VAL))) {
|
||||
deallocate_attr_in_db(p_db, p_char_decl);
|
||||
deallocate_attr_in_db(p_db, p_char_val);
|
||||
return 0;
|
||||
}
|
||||
@@ -733,7 +740,7 @@ tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
}
|
||||
|
||||
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
|
||||
|
||||
BOOLEAN found = FALSE;
|
||||
while (p_cur != NULL) {
|
||||
if (p_cur->handle == attr_handle) {
|
||||
/* for characteristic should not be set, return GATT_NOT_FOUND */
|
||||
@@ -758,13 +765,14 @@ tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
||||
} else{
|
||||
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
|
||||
p_cur->p_value->attr_val.attr_len = length;
|
||||
found = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
p_cur = p_cur->p_next;
|
||||
}
|
||||
|
||||
return GATT_SUCCESS;
|
||||
return found ? GATT_SUCCESS : GATT_NOT_FOUND;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1205,8 +1213,8 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
|
||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHORIZATION,handle %04x,perm %04x", handle, perm);
|
||||
}
|
||||
/* LE security mode 2 attribute */
|
||||
else if (perm & GATT_WRITE_SIGNED_PERM && op_code != GATT_SIGN_CMD_WRITE && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)
|
||||
&& (perm & GATT_WRITE_ALLOWED) == 0) {
|
||||
else if ((perm & GATT_WRITE_SIGNED_PERM) && op_code != GATT_SIGN_CMD_WRITE && !(sec_flag & GATT_SEC_FLAG_ENCRYPTED)
|
||||
&& !(perm & (GATT_PERM_WRITE | GATT_PERM_WRITE_ENCRYPTED | GATT_PERM_WRITE_ENC_MITM))) {
|
||||
status = GATT_INSUF_AUTHENTICATION;
|
||||
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INSUF_AUTHENTICATION: LE security mode 2 required,handle %04x,perm %04x", handle, perm);
|
||||
} else { /* writable: must be char value declaration or char descriptors */
|
||||
|
||||
@@ -1174,27 +1174,25 @@ void gatt_init_srv_chg (void)
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
void gatt_proc_srv_chg (void)
|
||||
{
|
||||
UINT8 start_idx, found_idx;
|
||||
BD_ADDR bda;
|
||||
BOOLEAN srv_chg_ind_pending = FALSE;
|
||||
tGATT_TCB *p_tcb;
|
||||
tBT_TRANSPORT transport;
|
||||
list_node_t *p_node = NULL;
|
||||
|
||||
GATT_TRACE_DEBUG ("gatt_proc_srv_chg");
|
||||
|
||||
if (gatt_cb.cb_info.p_srv_chg_callback && gatt_cb.handle_of_h_r) {
|
||||
gatt_set_srv_chg();
|
||||
start_idx = 0;
|
||||
while (gatt_find_the_connected_bda(start_idx, bda, &found_idx, &transport)) {
|
||||
p_tcb = gatt_get_tcb_by_idx(found_idx);
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
|
||||
if (!srv_chg_ind_pending) {
|
||||
gatt_send_srv_chg_ind(bda);
|
||||
} else {
|
||||
GATT_TRACE_DEBUG ("discard srv chg - already has one in the queue");
|
||||
for (p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb->in_use && p_tcb->ch_state == GATT_CH_OPEN) {
|
||||
srv_chg_ind_pending = gatt_is_srv_chg_ind_pending(p_tcb);
|
||||
if (!srv_chg_ind_pending) {
|
||||
gatt_send_srv_chg_ind(p_tcb->peer_bda);
|
||||
} else {
|
||||
GATT_TRACE_DEBUG ("discard srv chg - already has one in the queue");
|
||||
}
|
||||
}
|
||||
start_idx = ++found_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +166,12 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status,
|
||||
|
||||
GATT_TRACE_DEBUG ("process_read_multi_rsp status=%d mtu=%d", status, mtu);
|
||||
|
||||
if (!p_msg) {
|
||||
p_cmd->status = GATT_INVALID_PDU;
|
||||
GATT_TRACE_ERROR("process_read_multi_rsp - invalid p_msg");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (p_cmd->multi_rsp_q == NULL) {
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
@@ -287,6 +293,12 @@ static BOOLEAN process_read_multi_var_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS sta
|
||||
|
||||
GATT_TRACE_DEBUG ("process_read_multi_var rsp status=%d mtu=%d", status, mtu);
|
||||
|
||||
if (!p_msg) {
|
||||
GATT_TRACE_ERROR("process_read_multi_var_rsp - invalid p_msg");
|
||||
p_cmd->status = GATT_INVALID_PDU;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (p_cmd->multi_rsp_q == NULL) {
|
||||
p_cmd->multi_rsp_q = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
}
|
||||
@@ -474,9 +486,11 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
|
||||
tGATT_IF gatt_if;
|
||||
UINT16 conn_id;
|
||||
UINT16 queue_num = 0;
|
||||
BOOLEAN is_first = TRUE;
|
||||
UINT16 zeroed_cap = 0, zeroed_count = 0;
|
||||
void **zeroed_attrs = NULL;
|
||||
BOOLEAN is_prepare_write_valid = FALSE;
|
||||
BOOLEAN is_need_dequeue_sr_cmd = FALSE;
|
||||
BOOLEAN sr_cmd_already_dequeued = FALSE;
|
||||
tGATT_PREPARE_WRITE_RECORD *prepare_record = NULL;
|
||||
tGATT_PREPARE_WRITE_QUEUE_DATA * queue_data = NULL;
|
||||
|
||||
@@ -517,6 +531,7 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
|
||||
gatt_exec_write_rsp.op_code = GATT_RSP_EXEC_WRITE;
|
||||
gatt_send_packet(p_tcb, (UINT8 *)(&gatt_exec_write_rsp), sizeof(gatt_exec_write_rsp));
|
||||
gatt_dequeue_sr_cmd(p_tcb);
|
||||
sr_cmd_already_dequeued = TRUE;
|
||||
if (flag != GATT_PREP_WRITE_CANCEL){
|
||||
is_prepare_write_valid = TRUE;
|
||||
}
|
||||
@@ -537,23 +552,99 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
|
||||
gatt_send_error_rsp(p_tcb, prepare_record->error_code_app, GATT_REQ_EXEC_WRITE, 0, is_need_dequeue_sr_cmd);
|
||||
}
|
||||
|
||||
//dequeue prepare write data
|
||||
/* Track which attributes we've zeroed so we only zero on first write per attribute.
|
||||
* Zeroing all up-front would leave attr_len=0 for attributes whose write is later
|
||||
* skipped (e.g. overflow), causing data loss. */
|
||||
if (is_prepare_write_valid && queue_num > 0) {
|
||||
zeroed_cap = queue_num; /* max unique attributes in this exec is at most queue_num */
|
||||
zeroed_attrs = (void **)osi_calloc(zeroed_cap * sizeof(void *));
|
||||
if (zeroed_attrs == NULL) {
|
||||
GATT_TRACE_ERROR("%s: no memory for zeroed_attrs, abort exec write", __func__);
|
||||
while (fixed_queue_try_peek_first(prepare_record->queue)) {
|
||||
queue_data = fixed_queue_dequeue(prepare_record->queue, FIXED_QUEUE_MAX_TIMEOUT);
|
||||
osi_free(queue_data);
|
||||
}
|
||||
fixed_queue_free(prepare_record->queue, NULL);
|
||||
prepare_record->queue = NULL;
|
||||
{
|
||||
UINT16 total_num_saved = prepare_record->total_num;
|
||||
prepare_record->total_num = 0;
|
||||
prepare_record->error_code_app = GATT_SUCCESS;
|
||||
/* Only send error (and dequeue via gatt_send_error_rsp) if we did not already send success and dequeue (first branch) */
|
||||
if (!sr_cmd_already_dequeued) {
|
||||
gatt_send_error_rsp(p_tcb, GATT_NO_RESOURCES, GATT_REQ_EXEC_WRITE, 0, TRUE);
|
||||
} else {
|
||||
/* Success already sent to peer; notify apps and clear prep_cnt so state stays consistent */
|
||||
if (!gatt_sr_is_prep_cnt_zero(p_tcb)) {
|
||||
if (total_num_saved > queue_num) {
|
||||
trans_id = gatt_sr_enqueue_cmd(p_tcb, op_code, 0);
|
||||
gatt_sr_copy_prep_cnt_to_cback_cnt(p_tcb);
|
||||
}
|
||||
for (i = 0; i < GATT_MAX_APPS; i++) {
|
||||
if (p_tcb->prep_cnt[i]) {
|
||||
gatt_if = (tGATT_IF) (i + 1);
|
||||
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, gatt_if);
|
||||
gatt_sr_send_req_callback(conn_id,
|
||||
trans_id,
|
||||
GATTS_REQ_TYPE_WRITE_EXEC,
|
||||
(tGATTS_DATA *)&flag);
|
||||
p_tcb->prep_cnt[i] = 0;
|
||||
}
|
||||
}
|
||||
/* OOM path: we enqueued sr_cmd but will not get app response flow; clear sr_cmd so later requests are not dropped */
|
||||
if (total_num_saved > queue_num) {
|
||||
gatt_dequeue_sr_cmd(p_tcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while(fixed_queue_try_peek_first(prepare_record->queue)) {
|
||||
queue_data = fixed_queue_dequeue(prepare_record->queue, FIXED_QUEUE_MAX_TIMEOUT);
|
||||
if (is_prepare_write_valid){
|
||||
if((queue_data->p_attr->p_value != NULL) && (queue_data->p_attr->p_value->attr_val.attr_val != NULL)){
|
||||
if(is_first) {
|
||||
//clear attr_val.attr_len before handle prepare write data
|
||||
queue_data->p_attr->p_value->attr_val.attr_len = 0;
|
||||
is_first = FALSE;
|
||||
UINT16 attr_max_len = queue_data->p_attr->p_value->attr_val.attr_max_len;
|
||||
if (queue_data->offset > attr_max_len ||
|
||||
queue_data->len > attr_max_len - queue_data->offset) {
|
||||
GATT_TRACE_ERROR("%s: exec write overflow prevented, offset=%u len=%u max=%u",
|
||||
__func__, queue_data->offset, queue_data->len, attr_max_len);
|
||||
} else {
|
||||
UINT16 k;
|
||||
BOOLEAN need_zero = TRUE;
|
||||
/* Zero attr_len only on first successful write to this attribute in this exec */
|
||||
if (zeroed_attrs != NULL) {
|
||||
for (k = 0; k < zeroed_count; k++) {
|
||||
if (zeroed_attrs[k] == (void *)queue_data->p_attr) {
|
||||
need_zero = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (need_zero) {
|
||||
queue_data->p_attr->p_value->attr_val.attr_len = 0;
|
||||
if (zeroed_attrs != NULL && zeroed_count < zeroed_cap) {
|
||||
zeroed_attrs[zeroed_count++] = (void *)queue_data->p_attr;
|
||||
}
|
||||
}
|
||||
memcpy(queue_data->p_attr->p_value->attr_val.attr_val + queue_data->offset,
|
||||
queue_data->value, queue_data->len);
|
||||
{
|
||||
UINT16 write_end = queue_data->offset + queue_data->len;
|
||||
if (write_end > queue_data->p_attr->p_value->attr_val.attr_len) {
|
||||
queue_data->p_attr->p_value->attr_val.attr_len = write_end;
|
||||
}
|
||||
}
|
||||
}
|
||||
memcpy(queue_data->p_attr->p_value->attr_val.attr_val+queue_data->offset, queue_data->value, queue_data->len);
|
||||
//don't forget to increase the attribute value length in the gatts database.
|
||||
queue_data->p_attr->p_value->attr_val.attr_len += queue_data->len;
|
||||
}
|
||||
}
|
||||
osi_free(queue_data);
|
||||
}
|
||||
if (zeroed_attrs != NULL) {
|
||||
osi_free(zeroed_attrs);
|
||||
}
|
||||
fixed_queue_free(prepare_record->queue, NULL);
|
||||
prepare_record->queue = NULL;
|
||||
|
||||
|
||||
@@ -56,6 +56,15 @@ static void attr_uuid_to_bt_uuid(void *p_attr, tBT_UUID *p_uuid)
|
||||
}
|
||||
}
|
||||
|
||||
static UINT8 get_uuid_stream_len(tBT_UUID uuid)
|
||||
{
|
||||
// gatt_build_uuid_to_stream always converts 32-bit UUID to 128-bit UUID
|
||||
if (uuid.len == LEN_UUID_32) {
|
||||
return LEN_UUID_128;
|
||||
}
|
||||
return uuid.len;
|
||||
}
|
||||
|
||||
static size_t calculate_database_info_size(void)
|
||||
{
|
||||
UINT8 i;
|
||||
@@ -71,17 +80,20 @@ static size_t calculate_database_info_size(void)
|
||||
if (p_attr->uuid == GATT_UUID_PRI_SERVICE ||
|
||||
p_attr->uuid == GATT_UUID_SEC_SERVICE) {
|
||||
// Service declaration
|
||||
len += 4 + p_attr->p_value->uuid.len;
|
||||
len += 4 + get_uuid_stream_len(p_attr->p_value->uuid);
|
||||
} else if (p_attr->uuid == GATT_UUID_INCLUDE_SERVICE) {
|
||||
// Included service declaration
|
||||
len += 8 + p_attr->p_value->incl_handle.service_type.len;
|
||||
len += 8 + get_uuid_stream_len(p_attr->p_value->incl_handle.service_type);
|
||||
} else if (p_attr->uuid == GATT_UUID_CHAR_DECLARE) {
|
||||
tBT_UUID char_uuid = {0};
|
||||
// Characteristic declaration
|
||||
if (p_attr->p_next == NULL) {
|
||||
GATT_TRACE_ERROR("%s: malformed DB, char decl at handle %u has no value attr",
|
||||
__func__, p_attr->handle);
|
||||
break;
|
||||
}
|
||||
p_attr = (tGATT_ATTR16 *)p_attr->p_next;
|
||||
attr_uuid_to_bt_uuid((void *)p_attr, &char_uuid);
|
||||
// Increment 1 to fetch characteristic uuid from value declaration attribute
|
||||
len += 7 + char_uuid.len;
|
||||
len += 7 + get_uuid_stream_len(char_uuid);
|
||||
} else if (p_attr->uuid == GATT_UUID_CHAR_DESCRIPTION ||
|
||||
p_attr->uuid == GATT_UUID_CHAR_CLIENT_CONFIG ||
|
||||
p_attr->uuid == GATT_UUID_CHAR_SRVR_CONFIG ||
|
||||
@@ -127,14 +139,17 @@ static void fill_database_info(UINT8 *p_data)
|
||||
gatt_build_uuid_to_stream(&p_data, p_attr->p_value->incl_handle.service_type);
|
||||
} else if (p_attr->uuid == GATT_UUID_CHAR_DECLARE) {
|
||||
tBT_UUID char_uuid = {0};
|
||||
// Characteristic declaration
|
||||
if (p_attr->p_next == NULL) {
|
||||
GATT_TRACE_ERROR("%s: malformed DB, char decl at handle %u has no value attr",
|
||||
__func__, p_attr->handle);
|
||||
break;
|
||||
}
|
||||
UINT16_TO_STREAM(p_data, p_attr->handle);
|
||||
UINT16_TO_STREAM(p_data, GATT_UUID_CHAR_DECLARE);
|
||||
UINT8_TO_STREAM(p_data, p_attr->p_value->char_decl.property);
|
||||
UINT16_TO_STREAM(p_data, p_attr->p_value->char_decl.char_val_handle);
|
||||
p_attr = (tGATT_ATTR16 *)p_attr->p_next;
|
||||
attr_uuid_to_bt_uuid((void *)p_attr, &char_uuid);
|
||||
// Increment 1 to fetch characteristic uuid from value declaration attribute
|
||||
gatt_build_uuid_to_stream(&p_data, char_uuid);
|
||||
} else if (p_attr->uuid == GATT_UUID_CHAR_DESCRIPTION ||
|
||||
p_attr->uuid == GATT_UUID_CHAR_CLIENT_CONFIG ||
|
||||
@@ -151,6 +166,7 @@ static void fill_database_info(UINT8 *p_data)
|
||||
// TODO: process extended properties descriptor
|
||||
if (p_attr->p_value->attr_val.attr_len == 2) {
|
||||
memcpy(p_data, p_attr->p_value->attr_val.attr_val, 2);
|
||||
p_data += 2;
|
||||
} else {
|
||||
UINT16_TO_STREAM(p_data, 0x0000);
|
||||
}
|
||||
@@ -171,6 +187,11 @@ tGATT_STATUS gatts_calculate_datebase_hash(BT_OCTET16 hash)
|
||||
|
||||
len = calculate_database_info_size();
|
||||
|
||||
if (len == 0) {
|
||||
memset(hash, 0, BT_OCTET16_LEN);
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
data_buf = (UINT8 *)osi_malloc(len);
|
||||
if (data_buf == NULL) {
|
||||
GATT_TRACE_ERROR ("%s failed to allocate buffer (%u)\n", __func__, len);
|
||||
@@ -227,6 +248,10 @@ void gatts_show_local_database(void)
|
||||
tBT_UUID char_uuid = {0};
|
||||
tGATT_ATTR16 *p_char_val;
|
||||
p_char_val = (tGATT_ATTR16 *)p_attr->p_next;
|
||||
if (p_char_val == NULL) {
|
||||
printf("characteristic (malformed - no value attr)\n");
|
||||
break;
|
||||
}
|
||||
attr_uuid_to_bt_uuid((void *)p_char_val, &char_uuid);
|
||||
|
||||
printf("%s\n", gatt_get_attr_name(p_attr->uuid));
|
||||
|
||||
@@ -74,7 +74,7 @@ const char *const op_code_name[] = {
|
||||
"ATT_OP_CODE_MAX"
|
||||
};
|
||||
|
||||
static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
@@ -216,11 +216,12 @@ tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid128, tB
|
||||
list_t *list = fixed_queue_get_list(gatt_cb.pending_new_srv_start_q);
|
||||
for (const list_node_t *node = list_begin(list); node != list_end(list);
|
||||
node = list_next(node)) {
|
||||
p_buf = (tGATTS_PENDING_NEW_SRV_START *)list_node(node);
|
||||
tGATTS_HNDL_RANGE *p = p_buf->p_new_srv_start;
|
||||
tGATTS_PENDING_NEW_SRV_START *p_temp = (tGATTS_PENDING_NEW_SRV_START *)list_node(node);
|
||||
tGATTS_HNDL_RANGE *p = p_temp->p_new_srv_start;
|
||||
if (gatt_uuid_compare(*p_app_uuid128, p->app_uuid128)
|
||||
&& gatt_uuid_compare (*p_svc_uuid, p->svc_uuid)
|
||||
&& (svc_inst == p->svc_inst)) {
|
||||
p_buf = p_temp;
|
||||
GATT_TRACE_DEBUG("gatt_sr_is_new_srv_chg: Yes");
|
||||
break;
|
||||
}
|
||||
@@ -449,19 +450,17 @@ void gatt_free_hdl_buffer(tGATT_HDL_LIST_ELEM *p)
|
||||
void gatt_free_srvc_db_buffer_app_id(tBT_UUID *p_app_id)
|
||||
{
|
||||
tGATT_HDL_LIST_ELEM *p_elem = &gatt_cb.hdl_list[0];
|
||||
tGATT_HDL_LIST_INFO *p_list_info = &gatt_cb.hdl_list_info;
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < GATT_MAX_SR_PROFILES; i ++, p_elem ++) {
|
||||
if (memcmp(p_app_id, &p_elem->asgn_range.app_uuid128, sizeof(tBT_UUID)) == 0) {
|
||||
/* Remove from linked list first */
|
||||
gatt_remove_an_item_from_list(p_list_info, p_elem);
|
||||
/* Free attribute value buffers */
|
||||
gatt_free_attr_value_buffer(p_elem);
|
||||
while (!fixed_queue_is_empty(p_elem->svc_db.svc_buffer)) {
|
||||
osi_free(fixed_queue_dequeue(p_elem->svc_db.svc_buffer, 0));
|
||||
}
|
||||
fixed_queue_free(p_elem->svc_db.svc_buffer, NULL);
|
||||
p_elem->svc_db.svc_buffer = NULL;
|
||||
|
||||
p_elem->svc_db.mem_free = 0;
|
||||
p_elem->svc_db.p_attr_list = p_elem->svc_db.p_free_mem = NULL;
|
||||
/* Free the handle buffer completely (including svc_buffer and setting in_use = FALSE) */
|
||||
gatt_free_hdl_buffer(p_elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -631,7 +630,17 @@ BOOLEAN gatt_remove_a_srv_from_list(tGATT_SRV_LIST_INFO *p_list, tGATT_SRV_LIST_
|
||||
p_remove->p_next->p_prev = p_remove->p_prev;
|
||||
p_remove->p_prev->p_next = p_remove->p_next;
|
||||
}
|
||||
p_list->count--;
|
||||
// If the list is now empty, update p_last to NULL
|
||||
if(p_list->p_first == NULL) {
|
||||
p_list->p_last = NULL;
|
||||
}
|
||||
if (p_list->count) {
|
||||
p_list->count --;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("Error: p_list->count is already zero");
|
||||
}
|
||||
|
||||
|
||||
gatt_update_last_pri_srv_info(p_list);
|
||||
return TRUE;
|
||||
|
||||
@@ -722,46 +731,20 @@ BOOLEAN gatt_remove_an_item_from_list(tGATT_HDL_LIST_INFO *p_list, tGATT_HDL_LIS
|
||||
p_remove->p_next->p_prev = p_remove->p_prev;
|
||||
p_remove->p_prev->p_next = p_remove->p_next;
|
||||
}
|
||||
p_list->count--;
|
||||
// If the list is now empty, update p_last to NULL
|
||||
if (p_list->p_first == NULL) {
|
||||
p_list->p_last = NULL;
|
||||
}
|
||||
|
||||
if(p_list->count > 0) {
|
||||
p_list->count--;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("Error: p_list->count is already zero");
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function gatt_find_the_connected_bda
|
||||
**
|
||||
** Description This function find the connected bda
|
||||
**
|
||||
** Returns TRUE if found
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found_idx,
|
||||
tBT_TRANSPORT *p_transport)
|
||||
{
|
||||
BOOLEAN found = FALSE;
|
||||
GATT_TRACE_DEBUG("gatt_find_the_connected_bda start_idx=%d", start_idx);
|
||||
tGATT_TCB *p_tcb = NULL;
|
||||
list_node_t *p_node = NULL;
|
||||
p_tcb = gatt_get_tcb_by_idx(start_idx);
|
||||
if (p_tcb) {
|
||||
for(p_node = list_get_node(gatt_cb.p_tcb_list, p_tcb); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb->in_use && p_tcb->ch_state == GATT_CH_OPEN) {
|
||||
memcpy( bda, p_tcb->peer_bda, BD_ADDR_LEN);
|
||||
*p_found_idx = p_tcb->tcb_idx;
|
||||
*p_transport = p_tcb->transport;
|
||||
found = TRUE;
|
||||
GATT_TRACE_DEBUG("gatt_find_the_connected_bda bda :%02x-%02x-%02x-%02x-%02x-%02x",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GATT_TRACE_DEBUG("gatt_find_the_connected_bda found=%d found_idx=%d", found, p_tcb->tcb_idx);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -814,11 +797,11 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
|
||||
p_buf = (tGATTS_SRV_CHG *)list_node(node);
|
||||
if (!memcmp( bda, p_buf->bda, BD_ADDR_LEN)) {
|
||||
GATT_TRACE_DEBUG("bda is in the srv chg clt list");
|
||||
break;
|
||||
return p_buf;
|
||||
}
|
||||
}
|
||||
|
||||
return p_buf;
|
||||
return NULL;
|
||||
}
|
||||
#endif // (GATTS_INCLUDED == TRUE)
|
||||
|
||||
@@ -1023,11 +1006,11 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
|
||||
allocated = TRUE;
|
||||
}
|
||||
if (i != GATT_INDEX_INVALID) {
|
||||
p_tcb = gatt_tcb_alloc(i);
|
||||
if (!p_tcb) {
|
||||
return NULL;
|
||||
}
|
||||
if (allocated) {
|
||||
p_tcb = gatt_tcb_alloc(i);
|
||||
if (!p_tcb) {
|
||||
return NULL;
|
||||
}
|
||||
memset(p_tcb, 0, sizeof(tGATT_TCB));
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
p_tcb->pending_enc_clcb = fixed_queue_new(QUEUE_SIZE_MAX);
|
||||
@@ -1035,6 +1018,11 @@ tGATT_TCB *gatt_allocate_tcb_by_bdaddr(BD_ADDR bda, tBT_TRANSPORT transport)
|
||||
p_tcb->in_use = TRUE;
|
||||
p_tcb->tcb_idx = i;
|
||||
p_tcb->transport = transport;
|
||||
} else {
|
||||
p_tcb = gatt_get_tcb_by_idx(i);
|
||||
if (!p_tcb) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
memcpy(p_tcb->peer_bda, bda, BD_ADDR_LEN);
|
||||
#if GATTS_ROBUST_CACHING_ENABLED
|
||||
@@ -1736,14 +1724,18 @@ tGATT_CLCB *gatt_clcb_alloc (UINT16 conn_id)
|
||||
if (list_length(gatt_cb.p_clcb_list) < GATT_CL_MAX_LCB) {
|
||||
p_clcb = (tGATT_CLCB *)osi_malloc(sizeof(tGATT_CLCB));
|
||||
if (p_clcb) {
|
||||
list_append(gatt_cb.p_clcb_list, p_clcb);
|
||||
memset(p_clcb, 0, sizeof(tGATT_CLCB));
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
//Add index of the clcb same as conn_id
|
||||
p_clcb->clcb_idx = conn_id;
|
||||
p_clcb->p_reg = p_reg;
|
||||
p_clcb->p_tcb = p_tcb;
|
||||
if (!list_append(gatt_cb.p_clcb_list, p_clcb)) {
|
||||
osi_free(p_clcb);
|
||||
GATT_TRACE_ERROR("gatt_clcb_alloc: could not add clcb to list");
|
||||
return NULL;
|
||||
}
|
||||
memset(p_clcb, 0, sizeof(tGATT_CLCB));
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
//Add index of the clcb same as conn_id
|
||||
p_clcb->clcb_idx = conn_id;
|
||||
p_clcb->p_reg = p_reg;
|
||||
p_clcb->p_tcb = p_tcb;
|
||||
}
|
||||
}
|
||||
return p_clcb;
|
||||
@@ -1761,6 +1753,10 @@ tGATT_CLCB *gatt_clcb_alloc (UINT16 conn_id)
|
||||
void gatt_clcb_dealloc (tGATT_CLCB *p_clcb)
|
||||
{
|
||||
if (p_clcb && p_clcb->in_use) {
|
||||
if (p_clcb->p_attr_buf) {
|
||||
osi_free(p_clcb->p_attr_buf);
|
||||
p_clcb->p_attr_buf = NULL;
|
||||
}
|
||||
btu_free_timer(&p_clcb->rsp_timer_ent);
|
||||
memset(p_clcb, 0, sizeof(tGATT_CLCB));
|
||||
list_remove(gatt_cb.p_clcb_list, p_clcb);
|
||||
@@ -1787,10 +1783,10 @@ tGATT_TCB *gatt_find_tcb_by_cid (UINT16 lcid)
|
||||
for(p_node = list_begin(gatt_cb.p_tcb_list); p_node; p_node = list_next(p_node)) {
|
||||
p_tcb = list_node(p_node);
|
||||
if (p_tcb->in_use && p_tcb->att_lcid == lcid) {
|
||||
break;
|
||||
return p_tcb;
|
||||
}
|
||||
}
|
||||
return p_tcb;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1978,7 +1974,7 @@ void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
UINT8 idx = ((UINT8) gatt_if) - 1 ;
|
||||
|
||||
if (p_tcb) {
|
||||
if (p_tcb && idx < GATT_MAX_APPS) {
|
||||
if (is_reset_first) {
|
||||
gatt_sr_reset_cback_cnt(p_tcb);
|
||||
}
|
||||
@@ -2008,9 +2004,9 @@ void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc,
|
||||
UINT8 idx = ((UINT8) gatt_if) - 1 ;
|
||||
|
||||
GATT_TRACE_DEBUG("gatt_sr_update_prep_cnt tcb idx=%d gatt_if=%d is_inc=%d is_reset_first=%d",
|
||||
p_tcb->tcb_idx, gatt_if, is_inc, is_reset_first);
|
||||
p_tcb ? p_tcb->tcb_idx : 0, gatt_if, is_inc, is_reset_first);
|
||||
|
||||
if (p_tcb) {
|
||||
if (p_tcb && idx < GATT_MAX_APPS) {
|
||||
if (is_reset_first) {
|
||||
gatt_sr_reset_prep_cnt(p_tcb);
|
||||
}
|
||||
@@ -2173,6 +2169,11 @@ UINT8 gatt_send_write_msg (tGATT_TCB *p_tcb, UINT16 clcb_idx, UINT8 op_code,
|
||||
{
|
||||
tGATT_CL_MSG msg;
|
||||
|
||||
if (len > GATT_MAX_ATTR_LEN) {
|
||||
GATT_TRACE_ERROR("%s: len %u exceeds max %u", __func__, len, GATT_MAX_ATTR_LEN);
|
||||
return GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
msg.attr_value.handle = handle;
|
||||
msg.attr_value.len = len;
|
||||
msg.attr_value.offset = offset;
|
||||
@@ -2265,6 +2266,7 @@ void gatt_end_operation(tGATT_CLCB *p_clcb, tGATT_STATUS status, void *p_data)
|
||||
|
||||
if (p_clcb->p_attr_buf) {
|
||||
osi_free(p_clcb->p_attr_buf);
|
||||
p_clcb->p_attr_buf = NULL;
|
||||
}
|
||||
|
||||
#if !CONFIG_BT_STACK_NO_LOG
|
||||
@@ -2320,9 +2322,9 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
|
||||
GATT_TRACE_DEBUG ("found p_clcb conn_id=%d clcb_idx=%d", p_clcb->conn_id, p_clcb->clcb_idx);
|
||||
if (p_clcb->operation != GATTC_OPTYPE_NONE) {
|
||||
gatt_end_operation(p_clcb, GATT_ERROR, NULL);
|
||||
p_clcb = NULL;
|
||||
} else {
|
||||
gatt_clcb_dealloc(p_clcb);
|
||||
}
|
||||
gatt_clcb_dealloc(p_clcb);
|
||||
}
|
||||
}
|
||||
#if (GATTC_INCLUDED == TRUE)
|
||||
@@ -2540,7 +2542,7 @@ BOOLEAN gatt_add_bg_dev_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN is_init
|
||||
|
||||
if (i == 0) {
|
||||
// To check, we do not support background connection, code will not be called here
|
||||
ret = BTM_BleUpdateAdvWhitelist(TRUE, bd_addr, 0, NULL);
|
||||
ret = BTM_BleUpdateAdvWhitelist(TRUE, bd_addr, 0);
|
||||
} else {
|
||||
ret = TRUE;
|
||||
}
|
||||
@@ -2681,7 +2683,7 @@ BOOLEAN gatt_remove_bg_dev_from_list(tGATT_REG *p_reg, BD_ADDR bd_addr, BOOLEAN
|
||||
|
||||
if (p_dev->listen_gif[0] == 0) {
|
||||
// To check, we do not support background connection, code will not be called here
|
||||
ret = BTM_BleUpdateAdvWhitelist(FALSE, p_dev->remote_bda, 0, NULL);
|
||||
ret = BTM_BleUpdateAdvWhitelist(FALSE, p_dev->remote_bda, 0);
|
||||
} else {
|
||||
ret = TRUE;
|
||||
}
|
||||
@@ -2743,7 +2745,7 @@ void gatt_deregister_bgdev_list(tGATT_IF gatt_if)
|
||||
|
||||
if (p_dev_list->listen_gif[0] == 0) {
|
||||
// To check, we do not support background connection, code will not be called here
|
||||
BTM_BleUpdateAdvWhitelist(FALSE, p_dev_list->remote_bda, 0, NULL);
|
||||
BTM_BleUpdateAdvWhitelist(FALSE, p_dev_list->remote_bda, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,6 +603,8 @@ extern void gatt_set_err_rsp(BOOLEAN enable, UINT8 req_op_code, UINT8 err_status
|
||||
}
|
||||
#endif
|
||||
|
||||
extern const UINT8 base_uuid[LEN_UUID_128];
|
||||
|
||||
/* internal functions */
|
||||
extern void gatt_init (void);
|
||||
extern void gatt_free(void);
|
||||
@@ -658,7 +660,6 @@ extern tGATTS_PENDING_NEW_SRV_START *gatt_sr_is_new_srv_chg(tBT_UUID *p_app_uuid
|
||||
extern BOOLEAN gatt_is_srv_chg_ind_pending (tGATT_TCB *p_tcb);
|
||||
extern tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda);
|
||||
|
||||
extern BOOLEAN gatt_find_the_connected_bda(UINT8 start_idx, BD_ADDR bda, UINT8 *p_found_idx, tBT_TRANSPORT *p_transport);
|
||||
extern void gatt_set_srv_chg(void);
|
||||
extern void gatt_delete_dev_from_srv_chg_clt_list(BD_ADDR bd_addr);
|
||||
extern tGATTS_PENDING_NEW_SRV_START *gatt_add_pending_new_srv_start( tGATTS_HNDL_RANGE *p_new_srv_start);
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
static BlE_SYNC ble_sync_info;
|
||||
|
||||
void btsnd_hcic_ble_sync_sem_init(void)
|
||||
@@ -63,7 +63,7 @@ void btsnd_hci_ble_set_status(UINT8 hci_status)
|
||||
ble_sync_info.status = hci_status;
|
||||
return;
|
||||
}
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#endif // ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
|
||||
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
|
||||
|
||||
@@ -111,7 +111,7 @@ BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_bda)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 adv_type, UINT8 addr_type_own,
|
||||
UINT8 addr_type_dir, BD_ADDR direct_bda,
|
||||
UINT8 channel_map, UINT8 adv_filter_policy)
|
||||
@@ -119,7 +119,7 @@ BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_PARAMS)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -139,9 +139,9 @@ BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8_TO_STREAM (pp, channel_map);
|
||||
UINT8_TO_STREAM (pp, adv_filter_policy);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void)
|
||||
{
|
||||
BT_HDR *p;
|
||||
@@ -164,7 +164,7 @@ BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void)
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
|
||||
UINT8 btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
@@ -174,7 +174,7 @@ BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
|
||||
}
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_ADV_DATA + 1)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -197,17 +197,16 @@ BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data)
|
||||
|
||||
ARRAY_TO_STREAM (pp, p_data, data_len);
|
||||
}
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
|
||||
|
||||
UINT8 btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_RSP + 1)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -232,18 +231,16 @@ BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp)
|
||||
ARRAY_TO_STREAM (pp, p_scan_rsp, data_len);
|
||||
}
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable)
|
||||
UINT8 btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_WRITE_ADV_ENABLE)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -256,10 +253,10 @@ BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable)
|
||||
|
||||
UINT8_TO_STREAM (pp, adv_enable);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
|
||||
UINT8 btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 addr_type_own, UINT8 scan_filter_policy)
|
||||
{
|
||||
@@ -267,7 +264,7 @@ BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_PARAM)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -284,17 +281,16 @@ BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT8_TO_STREAM (pp, addr_type_own);
|
||||
UINT8_TO_STREAM (pp, scan_filter_policy);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate)
|
||||
UINT8 btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
if ((p = HCI_GET_CMD_BUF(HCIC_PARAM_SIZE_BLE_WRITE_SCAN_ENABLE)) == NULL) {
|
||||
return (FALSE);
|
||||
return HCI_ERR_MEMORY_FULL;
|
||||
}
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
@@ -308,8 +304,7 @@ BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate)
|
||||
UINT8_TO_STREAM (pp, scan_enable);
|
||||
UINT8_TO_STREAM (pp, duplicate);
|
||||
|
||||
btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return (TRUE);
|
||||
return btu_hcif_send_cmd_sync (LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
|
||||
/* link layer connection management commands */
|
||||
@@ -1103,6 +1098,16 @@ BOOLEAN btsnd_hcic_ble_set_channels (BLE_CHANNELS channels)
|
||||
p->offset = 0; \
|
||||
} while(0)
|
||||
|
||||
/* For UINT8-returning functions that call btu_hcif_send_cmd_sync (return HCI status) */
|
||||
#define HCIC_BLE_CMD_CREATED_U8(p, pp, size) do{\
|
||||
if ((p = HCI_GET_CMD_BUF(size)) == NULL) { \
|
||||
return HCI_ERR_MEMORY_FULL; \
|
||||
} \
|
||||
pp = p->data; \
|
||||
p->len = HCIC_PREAMBLE_SIZE + size;\
|
||||
p->offset = 0; \
|
||||
} while(0)
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_phy(UINT16 conn_handle)
|
||||
@@ -1129,7 +1134,7 @@ UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys,
|
||||
UINT8 *pp;
|
||||
|
||||
HCI_TRACE_EVENT("%s, all_phys = %d, tx_phys = %d, rx_phys = %d", __func__, all_phys, tx_phys, rx_phys);
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_DEFAULT_PHY);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BLE_SET_DEF_PHY);
|
||||
@@ -1217,7 +1222,7 @@ UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
|
||||
|
||||
UINT16_TO_STREAM (pp, HCI_BLE_SET_ADV_RAND_ADDR);
|
||||
UINT8_TO_STREAM (pp, HCIC_PARAM_SIZE_EXT_RAND_ADDR);
|
||||
@@ -1249,7 +1254,7 @@ UINT8 btsnd_hcic_ble_set_ext_adv_params_v2(UINT8 adv_handle, UINT16 properties,
|
||||
primary_adv_phy, secondary_adv_max_skip, secondary_adv_phy, adv_sid, scan_req_ntf_enable,
|
||||
primary_adv_phy_options, secondary_adv_phy_options);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS + 2);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS + 2);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_PARAM_V2);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS + 2);
|
||||
@@ -1295,7 +1300,7 @@ UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UIN
|
||||
channel_map, own_addr_type, peer_addr_type, adv_filter_policy, adv_tx_power,
|
||||
primary_adv_phy, secondary_adv_max_skip, secondary_adv_phy, adv_sid, scan_req_ntf_enable);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_PARAM);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS);
|
||||
@@ -1329,17 +1334,17 @@ UINT8 btsnd_hcic_ble_set_ext_adv_data(UINT8 adv_handle,
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\
|
||||
data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, data_len + 4);
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, data_len + 4);
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_ADV_DATA);
|
||||
UINT8_TO_STREAM(pp, data_len + 4);
|
||||
UINT8_TO_STREAM(pp, adv_handle);
|
||||
UINT8_TO_STREAM(pp, operation);
|
||||
UINT8_TO_STREAM(pp, fragment_prefrence);
|
||||
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
|
||||
if (p_data != NULL && data_len > 0){
|
||||
@@ -1361,7 +1366,11 @@ UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, fragment_prefrence = %d,\n\
|
||||
data_len = %d", __func__, adv_handle, operation, fragment_prefrence, data_len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, data_len + 4);
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, data_len + 4);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_RSP_DATA);
|
||||
UINT8_TO_STREAM(pp, data_len + 4);
|
||||
@@ -1369,12 +1378,6 @@ UINT8 btsnd_hcic_ble_set_ext_adv_scan_rsp_data(UINT8 adv_handle,
|
||||
UINT8_TO_STREAM(pp, operation);
|
||||
UINT8_TO_STREAM(pp, fragment_prefrence);
|
||||
|
||||
memset(pp, 0, data_len);
|
||||
|
||||
if (data_len > HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA) {
|
||||
data_len = HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, data_len);
|
||||
if (p_data != NULL && data_len > 0) {
|
||||
ARRAY_TO_STREAM (pp, p_data, data_len);
|
||||
@@ -1390,7 +1393,7 @@ UINT8 btsnd_hcic_ble_ext_adv_enable(UINT8 enable, UINT8 num_of_sets, UINT8 *adv_
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
UINT8 ext_adv_size = num_of_sets*4 + 2;
|
||||
HCIC_BLE_CMD_CREATED(p, pp, ext_adv_size);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, ext_adv_size);
|
||||
|
||||
HCI_TRACE_EVENT("%s, enable = %d, num_of_sets = %d", __func__, enable, num_of_sets);
|
||||
|
||||
@@ -1419,7 +1422,7 @@ UINT8 btsnd_hcic_ble_read_max_adv_len(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE + 1);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_RD_MAX_ADV_DATA_LEN);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_MAX_ADV_SIZE);
|
||||
@@ -1433,7 +1436,7 @@ UINT8 btsnd_hcic_ble_read_num_support_adv_set(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET + 1);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_RD_NUM_OF_ADV_SETS);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_NUM_SUPPORT_ADV_SET);
|
||||
@@ -1447,7 +1450,7 @@ UINT8 btsnd_hcic_ble_remove_adv_set(UINT8 adv_handle)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d", __func__, adv_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET + 1);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_ADV_SET);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_REMOVE_ADV_SET);
|
||||
@@ -1462,7 +1465,7 @@ UINT8 btsnd_hcic_ble_clear_adv_set(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET + 1);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_ADV_SETS);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_ADV_SET);
|
||||
@@ -1483,7 +1486,7 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_params_v2(UINT8 adv_handle, UINT16 interva
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d, interval_min = %d, interval_max = %d, propertics = %d num_subevents = %d subevent_interval = %d rsp_slot_delay %d rsp_slot_spacing %d num_rsp_slots %d",
|
||||
__func__, adv_handle, interval_min, interval_max, propertics, num_subevents, subevent_interval, rsp_slot_delay, rsp_slot_spacing, num_rsp_slots);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_PARAMS_V2);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS_V2);
|
||||
@@ -1513,7 +1516,7 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle,
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d, interval_min = %d, interval_max = %d, propertics = %d",
|
||||
__func__, adv_handle, interval_min, interval_max, propertics);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_PARAMS);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_SET_PERIODIC_ADV_PARAMS);
|
||||
@@ -1540,19 +1543,17 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_data(UINT8 adv_handle,
|
||||
HCI_TRACE_EVENT("%s, adv_handle = %d, operation = %d, len = %d",
|
||||
__func__, adv_handle, operation, len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, len + 3);
|
||||
if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
|
||||
len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, len + 3);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_DATA);
|
||||
UINT8_TO_STREAM(pp, len + 3);
|
||||
UINT8_TO_STREAM(pp, adv_handle);
|
||||
UINT8_TO_STREAM(pp, operation);
|
||||
|
||||
//memset(pp, 0, len);
|
||||
|
||||
if (len > HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA) {
|
||||
len = HCIC_PARAM_SIZE_WRITE_PERIODIC_ADV_DATA;
|
||||
}
|
||||
|
||||
UINT8_TO_STREAM (pp, len);
|
||||
|
||||
if (p_data != NULL && len > 0) {
|
||||
@@ -1570,7 +1571,7 @@ UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle)
|
||||
HCI_TRACE_EVENT("%s, enable = %d, adv_handle = %d",
|
||||
__func__, enable, adv_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_PERIOD_ADV_ENABLE);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_ENABLE);
|
||||
@@ -1593,7 +1594,7 @@ UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_polic
|
||||
__func__, own_addr_type, filter_policy, phy_mask, phy_count);
|
||||
UINT8 params_size = HCIC_PARAM_SIZE_SET_EXT_SCAN_PARAMS + phy_count*5;
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, params_size);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, params_size);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_PARAMS);
|
||||
UINT8_TO_STREAM(pp, params_size);
|
||||
@@ -1619,7 +1620,7 @@ UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups,
|
||||
HCI_TRACE_EVENT("%s, enable = %d, filter_dups = %d, duration = %d, period = %d",
|
||||
__func__, enable, filter_dups, duration, period);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_SET_EXT_SCAN_ENABLE);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_EXT_SCAN_ENABLE);
|
||||
@@ -1781,15 +1782,16 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn)
|
||||
#if (BLE_50_EXTEND_SYNC_EN == TRUE)
|
||||
BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid,
|
||||
UINT8 adv_addr_type, BD_ADDR adv_addr,
|
||||
UINT16 skip,
|
||||
UINT16 sync_timeout, UINT8 sync_cte_type)
|
||||
{
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s, option = %d, adv_sid = %d, adv_addr_type = %d, sync_timeout = %d, sync_cte_type = %d",
|
||||
__func__, option, adv_sid, adv_addr_type, sync_timeout, sync_cte_type);
|
||||
HCI_TRACE_EVENT("%s, option = %d, adv_sid = %d, adv_addr_type = %d, skip = %d, sync_timeout = %d, sync_cte_type = %d",
|
||||
__func__, option, adv_sid, adv_addr_type, skip, sync_timeout, sync_cte_type);
|
||||
|
||||
HCI_TRACE_EVENT("addr %02x %02x %02x %02x %02x %02x", adv_addr[0], adv_addr[1], adv_addr[2], adv_addr[3], adv_addr[4], adv_addr[5]);
|
||||
uint16_t skip = 0;
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC + 2);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC);
|
||||
@@ -1812,7 +1814,7 @@ UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_CREATE_SYNC_CANCEL);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_CREATE_SYNC_CANCEL);
|
||||
@@ -1826,7 +1828,7 @@ UINT8 btsnd_hcic_ble_periodic_adv_term_sync(UINT16 sync_handle)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s, sync_handle = %d", __func__, sync_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_PERIOD_ADV_TERM_SYNC);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_PERIODIC_ADV_TERM_SYNC);
|
||||
@@ -1844,7 +1846,7 @@ UINT8 btsnd_hcic_ble_add_dev_to_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR a
|
||||
HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
|
||||
esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_ADV_DEV_TO_PERIOD_ADV_LIST);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_ADD_DEV_TO_PERIODIC_ADV_LIST);
|
||||
@@ -1863,7 +1865,7 @@ UINT8 btsnd_hcic_ble_rm_dev_from_periodic_adv_list(UINT8 adv_addr_type, BD_ADDR
|
||||
HCI_TRACE_EVENT("%s, adv_addr_type = %d, adv_sid = %d", __func__, adv_addr_type, adv_sid);
|
||||
esp_log_buffer_hex_internal("addr", adv_addr, sizeof(BD_ADDR), ESP_LOG_WARN);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_REMOVE_DEV_FROM_PERIOD_ADV_LIST);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_RM_DEV_FROM_PERIODIC_ADV_LIST);
|
||||
@@ -1881,7 +1883,7 @@ UINT8 btsnd_hcic_ble_clear_periodic_adv_list(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_CLEAR_PERIOD_ADV_LIST);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_CLEAR_PERIODIC_ADV_LIST);
|
||||
@@ -1895,7 +1897,7 @@ UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_RD_PERIOD_ADV_LIST_SIZE);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_PERIODIC_ADV_LIST);
|
||||
@@ -1910,7 +1912,7 @@ UINT8 btsnd_hcic_ble_read_trans_power(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_RD_TRANSMIT_POWER);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_TRANS_POWER);
|
||||
@@ -1924,7 +1926,7 @@ UINT8 btsnd_hcic_ble_read_rf_path_compensation(void)
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s", __func__);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_RD_RF_PATH_COMPENSATION);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION);
|
||||
@@ -1938,7 +1940,7 @@ UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_
|
||||
UINT8 *pp;
|
||||
HCI_TRACE_EVENT("%s, rf_tx_path = %d, rf_rx_path = %d", __func__, rf_tx_path, rf_rx_path);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -1949,7 +1951,7 @@ UINT8 btsnd_hcic_ble_write_rf_path_compensation(UINT16 rf_tx_path, UINT16 rf_rx_
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION);
|
||||
|
||||
UINT16_TO_STREAM(pp, rf_tx_path);
|
||||
UINT16_TO_STREAM(pp, rf_tx_path);
|
||||
UINT16_TO_STREAM(pp, rf_rx_path);
|
||||
|
||||
return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
}
|
||||
@@ -1961,7 +1963,7 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_recv_enable(UINT16 sync_handle, UINT8 enab
|
||||
BT_HDR *p;
|
||||
UINT8 *pp;
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_PERIODIC_ADV_RECV_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2047,7 +2049,7 @@ UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT
|
||||
|
||||
HCI_TRACE_DEBUG("%s mode %x, skip %x, sync timeout %x", __func__, mode, skip, sync_timeout);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_PAST_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2157,7 +2159,7 @@ BOOLEAN btsnd_hcic_ble_set_vendor_evt_mask (UINT32 evt_mask)
|
||||
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
UINT8 btsnd_hcic_ble_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
|
||||
uint32_t sdu_interval, uint16_t max_sdu, uint16_t max_transport_latency,
|
||||
uint8_t rtn, uint8_t phy, uint8_t packing, uint8_t framing,
|
||||
@@ -2255,7 +2257,7 @@ UINT8 btsnd_hcic_ble_big_terminate(uint8_t big_handle, uint8_t reason)
|
||||
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
return TRUE;
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
UINT8 btsnd_hcic_ble_big_sync_create(uint8_t big_handle, uint16_t sync_handle,
|
||||
uint8_t encryption, uint8_t *bc_code,
|
||||
@@ -2267,17 +2269,19 @@ UINT8 btsnd_hcic_ble_big_sync_create(uint8_t big_handle, uint16_t sync_handle,
|
||||
|
||||
HCI_TRACE_DEBUG("big sync create: big_handle %d sync_handle %d encryption %d mse %d big_sync_timeout %d", big_handle, sync_handle, encryption, mse, big_sync_timeout);
|
||||
|
||||
// for (uint8_t i = 0; i < num_bis; i++)
|
||||
// {
|
||||
// HCI_TRACE_ERROR("i %d bis %d", bis[i]);
|
||||
// }
|
||||
#define HCIC_PARAM_SIZE_BIG_SYNC_CREATE_FIXED 24
|
||||
if (num_bis > (HCIC_PARAM_SIZE_BIG_SYNC_CREATE_PARAMS - HCIC_PARAM_SIZE_BIG_SYNC_CREATE_FIXED)) {
|
||||
HCI_TRACE_ERROR("%s: num_bis %u exceeds max", __func__, num_bis);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BIG_SYNC_CREATE_PARAMS);
|
||||
UINT8 param_size = HCIC_PARAM_SIZE_BIG_SYNC_CREATE_FIXED + num_bis;
|
||||
HCIC_BLE_CMD_CREATED(p, pp, param_size);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
UINT16_TO_STREAM(pp, HCI_BLE_BIG_CREATE_SYNC);
|
||||
UINT8_TO_STREAM(pp, HCIC_PARAM_SIZE_BIG_SYNC_CREATE_PARAMS);
|
||||
UINT8_TO_STREAM(pp, param_size);
|
||||
|
||||
UINT8_TO_STREAM(pp, big_handle);
|
||||
UINT16_TO_STREAM(pp, sync_handle);
|
||||
@@ -2299,7 +2303,7 @@ UINT8 btsnd_hcic_ble_big_sync_terminate(uint8_t big_handle)
|
||||
|
||||
HCI_TRACE_DEBUG("%s big_handle %d", __func__, big_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_BIG_SYNC_TERMINATE_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_BIG_SYNC_TERMINATE_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2321,7 +2325,7 @@ UINT8 btsnd_hcic_ble_iso_set_data_path(uint16_t conn_handle, uint8_t data_path_d
|
||||
HCI_TRACE_DEBUG("hci set data path: conn_handle %d data_path_dir %d data_path_id %d coding_fmt %d company_id 0x%x vs_codec_id %d controller_delay %ld codec_len %d",
|
||||
conn_handle, data_path_dir, data_path_id, coding_fmt, company_id, vs_codec_id, controller_delay, codec_len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_SET_DATA_PATH_PARAMS + codec_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_SET_DATA_PATH_PARAMS + codec_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2350,7 +2354,7 @@ UINT8 btsnd_hcic_ble_iso_remove_data_path(uint16_t conn_handle, uint8_t data_pat
|
||||
|
||||
HCI_TRACE_DEBUG("hci remove data path: conn_handle %d data_path_dir %d", conn_handle, data_path_dir);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_REMOVE_DATA_PATH_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_REMOVE_DATA_PATH_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2370,7 +2374,7 @@ UINT8 btsnd_hcic_ble_iso_read_tx_sync(uint16_t iso_hdl)
|
||||
|
||||
HCI_TRACE_DEBUG("hci read iso tx sync: iso_hdl %d", iso_hdl);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_READ_TX_SYNC_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_READ_TX_SYNC_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2391,7 +2395,7 @@ UINT8 btsnd_hcic_ble_iso_set_cig_params(uint8_t cig_id, uint32_t sdu_int_c_to_p,
|
||||
HCI_TRACE_DEBUG("hci set cig params: cig_id %d sdu_int_c_to_p %d sdu_int_p_to_c %d worse_case_SCA %d packing %d framing %d mtl_c_to_p %d mtl_p_to_c %d cis_cnt %d",
|
||||
cig_id, sdu_int_c_to_p, sdu_int_p_to_c, worse_case_SCA, packing, framing, mtl_c_to_p, mtl_p_to_c, cis_cnt);
|
||||
UINT8 cis_param_len = cis_cnt * 9;
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_SET_CIG_PARAMS + cis_param_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_SET_CIG_PARAMS + cis_param_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2432,7 +2436,7 @@ UINT8 btsnd_hcic_ble_iso_set_cig_params_test(uint8_t cig_id, uint32_t sdu_int_c_
|
||||
HCI_TRACE_DEBUG("hci set cig params test: cig_id %d sdu_int_c_to_p %d sdu_int_p_to_c %d ft_c_to_p %d ft_p_to_c %d iso_interval %d worse_case_SCA %d packing %d framing %d cis_cnt %d",
|
||||
cig_id, sdu_int_c_to_p, sdu_int_p_to_c, ft_c_to_p, ft_p_to_c, iso_interval, worse_case_SCA, packing, framing, cis_cnt);
|
||||
UINT8 cis_param_len = cis_cnt * 14;
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_SET_CIG_TEST_PARAMS + cis_param_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_SET_CIG_TEST_PARAMS + cis_param_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2506,7 +2510,7 @@ UINT8 btsnd_hcic_ble_iso_remove_cig(uint8_t cig_id)
|
||||
|
||||
HCI_TRACE_DEBUG("hci remove cig: cig_id %d", cig_id);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_REMOVE_CIG_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_REMOVE_CIG_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2548,7 +2552,7 @@ UINT8 btsnd_hcic_ble_iso_reject_cis_req(uint16_t cis_handle, uint8_t reason)
|
||||
|
||||
HCI_TRACE_DEBUG("hci reject cis req: cis_handle %d reason %d", cis_handle, reason);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_REJECT_CIS_REQ_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_REJECT_CIS_REQ_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2569,7 +2573,7 @@ UINT8 btsnd_hcic_ble_iso_read_iso_link_quality(uint16_t iso_handle)
|
||||
|
||||
HCI_TRACE_DEBUG("hci read iso link quality: cis_handle %d", iso_handle);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ISO_READ_LINK_QUALITY_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ISO_READ_LINK_QUALITY_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2593,7 +2597,7 @@ UINT8 btsnd_hcic_ble_set_connless_cte_trans_params(uint8_t adv_hdl, uint8_t cte_
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connless cte trans: adv_hdl %d cte_len %d cte_type %d cte_cnt %d", adv_hdl, cte_len, cte_type, cte_cnt);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_CTE_TRANS_PARAMS + switching_pattern_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_CTE_TRANS_PARAMS + switching_pattern_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2620,7 +2624,7 @@ UINT8 btsnd_hcic_ble_set_connless_cte_enable(uint8_t adv_hdl, uint8_t cte_en)
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connect cte enable: adv_hdl %d cte_en %d", adv_hdl, cte_en);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_CTE_TRANS_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_CTE_TRANS_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2641,7 +2645,7 @@ UINT8 btsnd_hcic_ble_set_connless_iq_sampling_enable(uint16_t sync_hdl, uint8_t
|
||||
|
||||
HCI_TRACE_DEBUG("hci enable IQ sampling: sync_hdl %d sampling_en %d slot_dur %d", sync_hdl, sampling_en, slot_dur);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_IQ_SAMPLING_ENABLE + switching_pattern_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CONNLESS_IQ_SAMPLING_ENABLE + switching_pattern_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2671,7 +2675,7 @@ UINT8 btsnd_hcic_ble_set_conn_cte_receive_params(uint16_t conn_hdl, uint8_t samp
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connection cte receive params: conn_hdl %d sampling_en %d slot_dur %d", conn_hdl, sampling_en, slot_dur);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CONN_CTE_RECEIVE_PARAMS + switching_pattern_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CONN_CTE_RECEIVE_PARAMS + switching_pattern_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2697,7 +2701,7 @@ UINT8 btsnd_hcic_ble_set_conn_cte_trans_params(uint16_t conn_hdl, uint8_t cte_ty
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connection cte trans params: conn_hdl %d cte_type %d len %d", conn_hdl, cte_type, switching_pattern_len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CONN_CTE_TRANS_PARAMS + switching_pattern_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CONN_CTE_TRANS_PARAMS + switching_pattern_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2722,7 +2726,7 @@ UINT8 btsnd_hcic_ble_conn_cte_req_enable(uint16_t conn_hdl, uint8_t enable, uint
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connect cte request enable: conn_hdl %d enable %d cte_req_int %d req_cte_len %d req_cte_type %d", conn_hdl, enable, cte_req_int, req_cte_len, req_cte_type);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CONN_CTE_REQ_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CONN_CTE_REQ_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2745,7 +2749,7 @@ UINT8 btsnd_hcic_ble_conn_cte_rsp_enable(uint16_t conn_hdl, uint8_t enable)
|
||||
|
||||
HCI_TRACE_DEBUG("hci set connect cte response enable: conn_hdl %d enable %d", conn_hdl, enable);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_CONN_CTE_RSP_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_CONN_CTE_RSP_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2766,7 +2770,7 @@ UINT8 btsnd_hcic_ble_read_antenna_info(void)
|
||||
|
||||
HCI_TRACE_DEBUG("hci read antenna information");
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_READ_ANT_INFO);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_READ_ANT_INFO);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2785,7 +2789,7 @@ UINT8 btsnd_hcic_ble_enh_read_trans_power_level(uint16_t conn_handle, uint8_t ph
|
||||
|
||||
HCI_TRACE_DEBUG("hci enh read trans power level, conn_handle %d phy %d", conn_handle, phy);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_ENH_READ_TRANS_PWR_LEVEL);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_ENH_READ_TRANS_PWR_LEVEL);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2829,7 +2833,7 @@ UINT8 btsnd_hcic_ble_set_path_loss_rpt_params(uint16_t conn_handle, uint8_t high
|
||||
conn_handle, high_threshold, high_hysteresis, low_threshold,
|
||||
low_hysteresis, min_time_spent);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PATH_LOSS_REPORTING_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PATH_LOSS_REPORTING_PARAMS);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2852,7 +2856,7 @@ UINT8 btsnd_hcic_ble_set_path_loss_rpt_enable(uint16_t conn_handle, uint8_t enab
|
||||
UINT8 *pp;
|
||||
|
||||
HCI_TRACE_DEBUG("hci set path loss rpt en, conn_handle %d enable %d", conn_handle, enable);
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PATH_LOSS_REPORTING_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PATH_LOSS_REPORTING_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2871,7 +2875,7 @@ UINT8 btsnd_hcic_ble_set_trans_pwr_rpt_enable(uint16_t conn_handle, uint8_t loca
|
||||
UINT8 *pp;
|
||||
|
||||
HCI_TRACE_DEBUG("hci set trans power rpt en, conn_handle %d local_enable %d remote_enable %d", conn_handle, local_enable, remote_enable);
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_TRANS_PWR_REPORTING_ENABLE);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_TRANS_PWR_REPORTING_ENABLE);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2896,7 +2900,7 @@ UINT8 btsnd_hcic_ble_set_default_subrate(UINT16 subrate_min, UINT16 subrate_max,
|
||||
HCI_TRACE_DEBUG("hci set default subrate, subrate_min %d subrate_max %d max_latency %d continuation_number %d supervision_timeout %d",
|
||||
subrate_min, subrate_max, max_latency, continuation_number, supervision_timeout);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SUBRATE_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SUBRATE_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -2948,9 +2952,9 @@ UINT8 btsnd_hcic_ble_set_host_feature(uint16_t bit_num, uint8_t bit_val)
|
||||
|
||||
HCI_TRACE_DEBUG("hci set host feature: bit_num %d bit_val %d", bit_num, bit_val);
|
||||
#if (BLE_FEAT_ISO_60_EN == TRUE)
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_HOST_FEATURE_PARAMS_V2);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_HOST_FEATURE_PARAMS_V2);
|
||||
#else
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_HOST_FEATURE_PARAMS);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_HOST_FEATURE_PARAMS);
|
||||
#endif // #if (BLE_FEAT_ISO_60_EN == TRUE)
|
||||
pp = (UINT8 *)(p + 1);
|
||||
#if (BLE_FEAT_ISO_60_EN == TRUE)
|
||||
@@ -3078,7 +3082,7 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_subevt_data(UINT8 adv_handle, UINT8 num_su
|
||||
param_len += (4 + subevent_params[i].subevent_data_len);
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, param_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, param_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3109,7 +3113,7 @@ UINT8 btsnd_hcic_ble_set_periodic_adv_rsp_data(UINT16 sync_handle, UINT16 req_ev
|
||||
HCI_TRACE_DEBUG("hci set PA rsp data, sync_handle %d req_evt %d req_subevt %d rsp_subevt %d rsp_slot %d rsp_data_len %d",
|
||||
sync_handle, req_evt, req_subevt, rsp_subevt, rsp_slot, rsp_data_len);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PA_RESPONSE_DATA_PARAMS_LEN + rsp_data_len);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PA_RESPONSE_DATA_PARAMS_LEN + rsp_data_len);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3142,7 +3146,7 @@ UINT8 btsnd_hcic_ble_set_periodic_sync_subevt(UINT16 sync_handle, UINT16 periodi
|
||||
HCI_TRACE_DEBUG("subevt[%d] = %d", i, subevt[i]);
|
||||
}
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PA_SYNC_SUBEVT_PARAMS_LEN + num_subevents_to_sync);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PA_SYNC_SUBEVT_PARAMS_LEN + num_subevents_to_sync);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3220,7 +3224,7 @@ UINT8 btsnd_hcic_ble_cs_write_cached_remote_supported_capabilities(UINT16 conn_h
|
||||
NADM_random_capability, cs_sync_phys_supported, subfeatures_supported, T_IP1_times_supported, T_IP2_times_supported, T_FCS_times_supported,
|
||||
T_PM_times_supported, T_SW_times_supported, TX_SNR_capability);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_WRITE_CACHE_REMOTE_SUPP_CAPS_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_WRITE_CACHE_REMOTE_SUPP_CAPS_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3278,7 +3282,7 @@ UINT8 btsnd_hcic_ble_cs_set_default_settings(UINT16 conn_handle, UINT8 role_enab
|
||||
|
||||
HCI_TRACE_DEBUG("cs set default settings, conn_handle %d role_enable %d cs_sync_ant_selection %d max_tx_power %d", conn_handle, role_enable, cs_sync_ant_selection, max_tx_power);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SETTINGS_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_DEFAULT_SETTINGS_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3319,7 +3323,7 @@ UINT8 btsnd_hcic_ble_cs_write_cached_remote_fae_table(UINT16 conn_handle, UINT8
|
||||
HCI_TRACE_DEBUG("cs write cached remote fae table, conn_handle %d", conn_handle);
|
||||
esp_log_buffer_hex_internal("remote_fae_table", remote_fae_table, 72, ESP_LOG_DEBUG);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_WRITE_CACHED_REMOTE_FAE_TAB_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3407,7 +3411,7 @@ UINT8 btsnd_hcic_ble_cs_set_channel_classification(UINT8 *channel_class)
|
||||
HCI_TRACE_DEBUG("cs set channel class");
|
||||
esp_log_buffer_hex_internal("channel", channel_class, 10, ESP_LOG_DEBUG);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_CHANNEL_CLASS_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_CHANNEL_CLASS_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3435,7 +3439,7 @@ UINT8 btsnd_hcic_ble_cs_set_procedure_params(UINT16 conn_handle, UINT8 config_id
|
||||
conn_handle, config_id, max_procedure_len, min_procedure_interval, max_procedure_interval, max_procedure_count, min_subevent_len, max_subevent_len,
|
||||
tone_ant_config_selection, phy, tx_power_delta, preferred_peer_antenna, SNR_control_initiator, SNR_control_reflector);
|
||||
|
||||
HCIC_BLE_CMD_CREATED(p, pp, HCIC_PARAM_SIZE_SET_PROCEDURE_PARAMS_LEN);
|
||||
HCIC_BLE_CMD_CREATED_U8(p, pp, HCIC_PARAM_SIZE_SET_PROCEDURE_PARAMS_LEN);
|
||||
|
||||
pp = (UINT8 *)(p + 1);
|
||||
|
||||
@@ -3476,7 +3480,7 @@ UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UI
|
||||
UINT8_TO_STREAM(pp, config_id);
|
||||
UINT8_TO_STREAM(pp, enable);
|
||||
|
||||
btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
btu_hcif_send_cmd(LOCAL_BR_EDR_CONTROLLER_ID, p);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -260,6 +260,7 @@ typedef struct {
|
||||
|
||||
#define STREAM_SKIP_UINT8(p) do { (p) += 1; } while (0)
|
||||
#define STREAM_SKIP_UINT16(p) do { (p) += 2; } while (0)
|
||||
#define STREAM_SKIP_UINT24(p) do { (p) += 3; } while (0)
|
||||
|
||||
/********************************************************************************
|
||||
** Macros to get and put bytes to and from a field (Little Endian format).
|
||||
|
||||
@@ -171,23 +171,13 @@ typedef void (tBTM_VSC_CMPL_CB) (tBTM_VSC_CMPL *p1);
|
||||
** Parameters are the BD Address of remote and the Dev Class of remote.
|
||||
** If the app returns none zero, the connection or inquiry result will be dropped.
|
||||
*/
|
||||
typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
|
||||
|
||||
typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params);
|
||||
|
||||
typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
|
||||
// typedef UINT8 (tBTM_FILTER_CB) (BD_ADDR bd_addr, DEV_CLASS dc);
|
||||
|
||||
typedef void (tBTM_DTM_CMD_CMPL_CBACK) (void *p1);
|
||||
|
||||
typedef void (tBTM_SET_RAND_ADDR_CBACK) (UINT8 status);
|
||||
|
||||
typedef void (tBTM_UPDATE_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
|
||||
|
||||
typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);
|
||||
|
||||
typedef void (tBTM_SET_RPA_TIMEOUT_CMPL_CBACK) (UINT8 status);
|
||||
|
||||
typedef void (tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK) (UINT8 status);
|
||||
// typedef void (tBTM_UPDATE_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
|
||||
|
||||
typedef void (tBTM_BLE_VENDOR_HCI_EVT_CBACK) (UINT8 subevt_code, UINT8 param_len, UINT8 *params);
|
||||
/*******************************
|
||||
@@ -865,16 +855,6 @@ typedef struct {
|
||||
BD_ADDR rem_bda; /* Remote device Bluetooth address */
|
||||
} tBTM_BLE_CH_MAP_RESULTS;
|
||||
|
||||
/* Structure returned with read current TX power event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadTxPower call.
|
||||
*/
|
||||
typedef struct {
|
||||
tBTM_STATUS status;
|
||||
UINT8 hci_status;
|
||||
INT8 tx_power;
|
||||
BD_ADDR rem_bda;
|
||||
} tBTM_TX_POWER_RESULTS;
|
||||
|
||||
/* Structure returned with read link quality event (in tBTM_CMPL_CB callback function)
|
||||
** in response to BTM_ReadLinkQuality call.
|
||||
*/
|
||||
@@ -3177,7 +3157,7 @@ tBTM_STATUS BTM_WriteBredrTxPwrLvl(tBTM_TX_PWR_LVL_TYPE type, INT8 tx_power, tBT
|
||||
** Returns BTM_CMD_STARTED if successfully initiated or error code
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda, tBTM_CMPL_CB *p_cb);
|
||||
tBTM_STATUS BTM_ReadChannelMap(BD_ADDR remote_bda);
|
||||
|
||||
void BTM_BleGetWhiteListSize(uint16_t *length);
|
||||
|
||||
@@ -4490,7 +4470,7 @@ tBTM_STATUS BTM_SetAfhChannels (AFH_CHANNELS channels, tBTM_CMPL_CB *p_afh_chann
|
||||
** Returns status of the operation
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels, tBTM_CMPL_CB *p_ble_channels_cmpl_cback);
|
||||
tBTM_STATUS BTM_BleSetChannels (BLE_CHANNELS channels);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -867,17 +867,8 @@ typedef void (tBTM_BLE_VERIFY_CBACK)(void *p_ref_data, BOOLEAN match);
|
||||
typedef void (tBTM_BLE_RANDOM_SET_CBACK) (BD_ADDR random_bda);
|
||||
|
||||
typedef void (tBTM_BLE_SCAN_REQ_CBACK)(BD_ADDR remote_bda, tBLE_ADDR_TYPE addr_type, UINT8 adv_evt);
|
||||
typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS status);
|
||||
|
||||
typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
|
||||
typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
|
||||
|
||||
typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info);
|
||||
typedef void (tBTM_CLEAR_ADV_CMPL_CBACK) (UINT8 status);
|
||||
typedef void (tBTM_SET_PRIVACY_MODE_CMPL_CBACK) (tBTM_STATUS status);
|
||||
typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status);
|
||||
typedef void (tBTM_SET_VENDOR_EVT_MASK_CBACK) (tBTM_STATUS status);
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1
|
||||
#define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2
|
||||
@@ -986,10 +977,10 @@ typedef void (tBTM_SET_VENDOR_EVT_MASK_CBACK) (tBTM_STATUS status);
|
||||
typedef UINT8 tBTM_BLE_5_GAP_EVENT;
|
||||
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#define BTM_BLE_ISO_BIG_CREATE_COMPLETE_EVT 1
|
||||
#define BTM_BLE_ISO_BIG_TERMINATE_COMPLETE_EVT 2
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
#define BTM_BLE_ISO_BIG_SYNC_ESTABLISHED_EVT 3
|
||||
#define BTM_BLE_ISO_BIG_SYNC_LOST_EVT 4
|
||||
@@ -1107,7 +1098,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
UINT8 status;
|
||||
UINT8 instance_num;
|
||||
UINT8 instance[10];
|
||||
UINT8 instance[MAX_BLE_ADV_INSTANCE];
|
||||
} tBTM_BLE_EXT_ADV_START_CMPL;
|
||||
|
||||
typedef struct {
|
||||
@@ -1558,7 +1549,7 @@ typedef struct {
|
||||
#endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
typedef struct {
|
||||
UINT8 status;
|
||||
UINT8 big_handle;
|
||||
@@ -1580,7 +1571,7 @@ typedef struct {
|
||||
UINT8 big_handle;
|
||||
UINT8 reason;
|
||||
} tBTM_BLE_BIG_TERMINATE_CMPL;
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
typedef struct {
|
||||
@@ -1725,10 +1716,10 @@ typedef struct {
|
||||
|
||||
typedef union {
|
||||
UINT8 status;
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
tBTM_BLE_BIG_CREATE_CMPL btm_big_cmpl;
|
||||
tBTM_BLE_BIG_TERMINATE_CMPL btm_big_term;
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
tBTM_BLE_BIG_SYNC_ESTAB_CMPL btm_big_sync_estab;
|
||||
tBTM_BLE_BIG_SYNC_LOST_EVT btm_big_sync_lost;
|
||||
@@ -1964,19 +1955,6 @@ extern "C" {
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleRegiseterConnParamCallback
|
||||
**
|
||||
** Description register connection parameters update callback func
|
||||
**
|
||||
** Parameters: update_conn_param_cb
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleRegiseterConnParamCallback(tBTM_UPDATE_CONN_PARAM_CBACK *update_conn_param_cb);
|
||||
void BTM_BleRegiseterPktLengthChangeCallback(tBTM_SET_PKT_DATA_LENGTH_CBACK *ptk_len_chane_cb);
|
||||
void BTM_BleRegisterVendorHciEventCallback(tBTM_BLE_VENDOR_HCI_EVT_CBACK *vendor_hci_evt_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2021,7 +1999,7 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleSetAdvParamsAll
|
||||
** Function BTM_BleStartAdvWithParams
|
||||
**
|
||||
** Description This function is called to set all of the advertising parameters.
|
||||
**
|
||||
@@ -2030,9 +2008,9 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key,
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetAdvParamsAll(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
|
||||
tBTM_STATUS BTM_BleStartAdvWithParams(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
|
||||
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2103,8 +2081,7 @@ void BTM_BleClearRandAddress(void);
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window,
|
||||
tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy,
|
||||
tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback);
|
||||
tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -2136,22 +2113,6 @@ tBTM_STATUS BTM_BleWriteScanRsp(tBTM_BLE_AD_MASK data_mask,
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleObserve
|
||||
**
|
||||
** Description This procedure keep the device listening for advertising
|
||||
** events from a broadcast device.
|
||||
**
|
||||
** Parameters start: start or stop observe.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration,
|
||||
tBTM_INQ_RESULTS_CB *p_results_cb, tBTM_CMPL_CB *p_cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleScan
|
||||
@@ -2596,17 +2557,17 @@ BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTM_BleBroadcast
|
||||
** Function BTM_BleAdvStop
|
||||
**
|
||||
** Description This function is to start or stop broadcasting.
|
||||
** Description This function is to stop broadcasting.
|
||||
**
|
||||
** Parameters start: start or stop broadcasting.
|
||||
** Parameters void
|
||||
**
|
||||
** Returns status.
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
|
||||
tBTM_STATUS BTM_BleAdvStop(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2621,7 +2582,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_st
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable, tBTM_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cabck);
|
||||
BOOLEAN BTM_BleConfigPrivacy(BOOLEAN enable);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2737,7 +2698,7 @@ void BTM_BleTurnOnPrivacyOnRemote(BD_ADDR bd_addr,
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type, tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
|
||||
BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_ADDR_TYPE addr_type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2748,7 +2709,7 @@ BOOLEAN BTM_BleUpdateAdvWhitelist(BOOLEAN add_remove, BD_ADDR emote_bda, tBLE_AD
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTM_BleClearWhitelist(tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb);
|
||||
void BTM_BleClearWhitelist(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2940,13 +2901,13 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length);
|
||||
** Parameters: subcode: add, remove or clean duplicate scan exceptional list.
|
||||
** type: device info type
|
||||
** device_info: device information
|
||||
** update_exceptional_list_cmp_cb: complete callback
|
||||
**
|
||||
**
|
||||
** Returns status
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
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_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type, BD_ADDR device_info);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2981,7 +2942,7 @@ BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize);
|
||||
** Parameter p_clear_adv_cback - Command complete callback
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback);
|
||||
BOOLEAN BTM_BleClearAdv(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2993,7 +2954,7 @@ BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback);
|
||||
** Parameter rpa_timeout - The timeout value for RPA, typically in seconds.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout, tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback);
|
||||
BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3006,15 +2967,14 @@ BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout, tBTM_SET_RPA_TIMEOUT_CMPL_CBA
|
||||
** Parameters addr - The address of the device to be added to the resolving list.
|
||||
** addr_type - The address type of the device (public or random).
|
||||
** irk - The Identity Resolving Key (IRK) of the device.
|
||||
** p_add_dev_to_resolving_list_callback - Callback function to be called when the operation is completed.
|
||||
**
|
||||
**
|
||||
** Returns TRUE if the operation was successful, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleAddDevToResolvingList(BD_ADDR addr,
|
||||
uint8_t addr_type,
|
||||
uint8_t irk[],
|
||||
tBTM_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_callback);
|
||||
uint8_t irk[]);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3032,8 +2992,7 @@ BOOLEAN BTM_BleAddDevToResolvingList(BD_ADDR addr,
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type,
|
||||
BD_ADDR bd_addr,
|
||||
UINT8 privacy_mode,
|
||||
tBTM_SET_PRIVACY_MODE_CMPL_CBACK *p_callback);
|
||||
UINT8 privacy_mode);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3047,7 +3006,7 @@ BOOLEAN BTM_BleSetPrivacyMode(UINT8 addr_type,
|
||||
** Returns TRUE if the operation was successful, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback);
|
||||
BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -3061,7 +3020,7 @@ BOOLEAN BTM_BleSetCsaSupport (UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK
|
||||
** Returns TRUE if the operation was successful, otherwise FALSE.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask, tBTM_SET_VENDOR_EVT_MASK_CBACK *p_callback);
|
||||
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask);
|
||||
/*
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
@@ -3140,7 +3099,7 @@ void BTM_BleSetPeriodicAdvSyncTransParams(BD_ADDR bd_addr, UINT8 mode, UINT16 sk
|
||||
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
void BTM_BleIsoRegisterCallback(tBTM_BLE_ISO_CBACK cb);
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
tBTM_STATUS BTM_BleBigCreate(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
|
||||
uint32_t sdu_interval, uint16_t max_sdu, uint16_t max_transport_latency,
|
||||
uint8_t rtn, uint8_t phy, uint8_t packing, uint8_t framing,
|
||||
@@ -3153,7 +3112,7 @@ tBTM_STATUS BTM_BleBigCreateTest(uint8_t big_handle, uint8_t adv_handle, uint8_t
|
||||
uint8_t pto, uint8_t encryption, uint8_t *broadcast_code);
|
||||
|
||||
tBTM_STATUS BTM_BleBigTerminate(UINT8 big_handle, UINT8 reason);
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
tBTM_STATUS BTM_BleBigSyncCreate(uint8_t big_handle, uint16_t sync_handle,
|
||||
uint8_t encryption, uint8_t *bc_code,
|
||||
|
||||
@@ -280,9 +280,7 @@ void btu_check_bt_sleep (void);
|
||||
*/
|
||||
void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
|
||||
void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf);
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
void btu_hcif_send_host_rdy_for_data(void);
|
||||
void btu_hcif_cmd_timeout (UINT8 controller_id);
|
||||
|
||||
|
||||
@@ -941,10 +941,10 @@
|
||||
#if (BLE_FEAT_ISO_EN == TRUE)
|
||||
#define HCI_BLE_CIS_ESTABLISHED_V1_EVT 0x19
|
||||
#define HCI_BLE_CIS_REQUEST_EVT 0x1A
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#define HCI_BLE_BIG_CREATE_COMPLETE_EVT 0x1B
|
||||
#define HCI_BLE_BIG_TERMINATE_COMPLETE_EVT 0x1C
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
#define HCI_BLE_BIG_SYNC_ESTABLISHED_EVT 0x1D
|
||||
#define HCI_BLE_BIG_SYNC_LOST_EVT 0x1E
|
||||
|
||||
@@ -799,7 +799,9 @@ void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode,
|
||||
#define HCIC_PARAM_SIZE_READ_TRANS_POWER 0
|
||||
#define HCIC_PARAM_SIZE_READ_RF_PATH_COMPENSATION 0
|
||||
#define HCIC_PARAM_SIZE_WRITE_RF_PATH_COMPENSATION 4
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
BlE_SYNC *btsnd_hcic_ble_get_sync_info(void);
|
||||
void btsnd_hcic_ble_sync_sem_init(void);
|
||||
void btsnd_hcic_ble_sync_sem_deinit(void);
|
||||
@@ -807,7 +809,7 @@ void btsnd_hcic_ble_sync_sem_deinit(void);
|
||||
uint8_t btsnd_hcic_ble_get_status(void);
|
||||
|
||||
void btsnd_hci_ble_set_status(UINT8 hci_status);
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#endif // ((BLE_50_FEATURE_SUPPORT == TRUE) || (BLE_42_FEATURE_SUPPORT == TRUE))
|
||||
|
||||
#if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
#define HCIC_PARAM_SIZE_ADD_MONITOR_ADV_LIST 10
|
||||
@@ -834,25 +836,24 @@ BOOLEAN btsnd_hcic_ble_set_local_used_feat (UINT8 feat_set[8]);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_random_addr (BD_ADDR random_addr);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 btsnd_hcic_ble_write_adv_params (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 adv_type, UINT8 addr_type_own,
|
||||
UINT8 addr_type_dir, BD_ADDR direct_bda,
|
||||
UINT8 channel_map, UINT8 adv_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_read_adv_chnl_tx_power (void);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
|
||||
UINT8 btsnd_hcic_ble_set_adv_data (UINT8 data_len, UINT8 *p_data);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
|
||||
UINT8 btsnd_hcic_ble_set_scan_rsp_data (UINT8 data_len, UINT8 *p_scan_rsp);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
|
||||
UINT8 btsnd_hcic_ble_set_adv_enable (UINT8 adv_enable);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT8 btsnd_hcic_ble_set_scan_params (UINT8 scan_type,
|
||||
UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 addr_type, UINT8 scan_filter_policy);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
|
||||
|
||||
UINT8 btsnd_hcic_ble_set_scan_enable (UINT8 scan_enable, UINT8 duplicate);
|
||||
BOOLEAN btsnd_hcic_ble_create_ll_conn (UINT16 scan_int, UINT16 scan_win,
|
||||
UINT8 init_filter_policy, UINT8 addr_type_peer, BD_ADDR bda_peer, UINT8 addr_type_own,
|
||||
UINT16 conn_int_min, UINT16 conn_int_max, UINT16 conn_latency, UINT16 conn_timeout,
|
||||
@@ -1061,6 +1062,7 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn_v2(tHCI_CreatExtConn *p_conn);
|
||||
|
||||
BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 filter_policy, UINT8 adv_sid,
|
||||
UINT8 adv_addr_type, BD_ADDR adv_addr,
|
||||
UINT16 skip,
|
||||
UINT16 sync_timeout, UINT8 sync_cte_type);
|
||||
|
||||
UINT8 btsnd_hcic_ble_periodic_adv_create_sync_cancel(void);
|
||||
@@ -1119,11 +1121,11 @@ UINT8 btsnd_hcic_ble_set_default_periodic_adv_sync_trans_params(UINT8 mode, UINT
|
||||
#define HCIC_PARAM_SIZE_ISO_ACCEPT_CIS_REQ_PARAMS 2
|
||||
#define HCIC_PARAM_SIZE_ISO_REJECT_CIS_REQ_PARAMS 3
|
||||
#define HCIC_PARAM_SIZE_ISO_READ_LINK_QUALITY_PARAMS 2
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#define HCIC_PARAM_SIZE_BIG_CREATE_PARAMS 31
|
||||
#define HCIC_PARAM_SIZE_BIG_CREATE_TEST_PARAMS 36
|
||||
#define HCIC_PARAM_SIZE_BIG_TERMINATE_PARAMS 2
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
#define HCIC_PARAM_SIZE_BIG_SYNC_CREATE_PARAMS 55
|
||||
#define HCIC_PARAM_SIZE_BIG_SYNC_TERMINATE_PARAMS 1
|
||||
@@ -1174,7 +1176,7 @@ UINT8 btsnd_hcic_ble_iso_accept_cis_req(uint16_t cis_handle);
|
||||
UINT8 btsnd_hcic_ble_iso_reject_cis_req(uint16_t cis_handle, uint8_t reason);
|
||||
#endif // #if (BLE_FEAT_ISO_CIG_PERIPHERAL_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
UINT8 btsnd_hcic_ble_big_create(uint8_t big_handle, uint8_t adv_handle, uint8_t num_bis,
|
||||
uint32_t sdu_interval, uint16_t max_sdu, uint16_t max_transport_latency,
|
||||
uint8_t rtn, uint8_t phy, uint8_t packing, uint8_t framing,
|
||||
@@ -1187,7 +1189,7 @@ UINT8 btsnd_hcic_ble_big_create_test(uint8_t big_handle, uint8_t adv_handle, uin
|
||||
uint8_t pto, uint8_t encryption, uint8_t *broadcast_code);
|
||||
|
||||
UINT8 btsnd_hcic_ble_big_terminate(uint8_t big_handle, uint8_t reason);
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROCASTER_EN == TRUE)
|
||||
#endif // #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ISO_BIG_SYNCER_EN == TRUE)
|
||||
UINT8 btsnd_hcic_ble_big_sync_create(uint8_t big_handle, uint16_t sync_handle,
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#define SMP_OPCODE_MAX SMP_OPCODE_PAIR_KEYPR_NOTIF
|
||||
#define SMP_OPCODE_MIN SMP_OPCODE_PAIRING_REQ
|
||||
#define SMP_OPCODE_PAIR_COMMITM 0x0F
|
||||
#define SMP_OPCODE_ARRAY_SIZE (SMP_OPCODE_PAIR_COMMITM + 1)
|
||||
// #endif
|
||||
|
||||
/* SMP event type */
|
||||
@@ -465,10 +466,10 @@ extern void SMP_SecureConnectionOobDataReply(UINT8 *p_data);
|
||||
** Description This function is called to encrypt the data with the specified
|
||||
** key
|
||||
**
|
||||
** Parameters: key - Pointer to key key[0] conatins the MSB
|
||||
** Parameters: key - Pointer to key key[0] contains the MSB
|
||||
** key_len - key length
|
||||
** plain_text - Pointer to data to be encrypted
|
||||
** plain_text[0] conatins the MSB
|
||||
** plain_text[0] contains the MSB
|
||||
** pt_len - plain text length
|
||||
** p_out - pointer to the encrypted outputs
|
||||
**
|
||||
|
||||
@@ -461,7 +461,7 @@ typedef struct t_l2c_linkcb {
|
||||
*/
|
||||
/* create connection retry count*/
|
||||
UINT8 retry_create_con;
|
||||
UINT32 start_time_s;
|
||||
int64_t start_time_s;
|
||||
#endif
|
||||
|
||||
#if (L2CAP_ROUND_ROBIN_CHANNEL_SERVICE == TRUE)
|
||||
@@ -736,7 +736,7 @@ extern void l2c_link_timeout (tL2C_LCB *p_lcb);
|
||||
extern void l2c_info_timeout (tL2C_LCB *p_lcb);
|
||||
extern void l2c_link_check_send_pkts (tL2C_LCB *p_lcb, tL2C_CCB *p_ccb, BT_HDR *p_buf);
|
||||
extern void l2c_link_adjust_allocation (void);
|
||||
extern void l2c_link_process_num_completed_pkts (UINT8 *p);
|
||||
extern void l2c_link_process_num_completed_pkts (UINT8 *p, UINT8 evt_len);
|
||||
extern void l2c_link_process_num_completed_blocks (UINT8 controller_id, UINT8 *p, UINT16 evt_len);
|
||||
extern void l2c_link_processs_num_bufs (UINT16 num_lm_acl_bufs);
|
||||
extern UINT8 l2c_link_pkts_rcvd (UINT16 *num_pkts, UINT16 *handles);
|
||||
|
||||
@@ -1863,6 +1863,11 @@ UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf)
|
||||
|
||||
BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, BD_ADDR addr)
|
||||
{
|
||||
if ((fixed_cid < L2CAP_FIRST_FIXED_CHNL) || (fixed_cid > L2CAP_LAST_FIXED_CHNL)) {
|
||||
L2CAP_TRACE_ERROR ("L2CA_CheckIsCongest() Invalid CID: 0x%04x", fixed_cid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
tL2C_LCB *p_lcb;
|
||||
p_lcb = l2cu_find_lcb_by_bd_addr(addr, BT_TRANSPORT_LE);
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "btm_int.h"
|
||||
#include "stack/hcimsgs.h"
|
||||
#include "device/controller.h"
|
||||
#include "bta_dm_gap.h"
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
|
||||
@@ -171,14 +172,18 @@ BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bda, UINT16 min_int, UINT16 max_in
|
||||
L2CAP_TRACE_ERROR("%s connection parameter update in progress, please try later", __func__);
|
||||
}
|
||||
|
||||
if ((need_cb == TRUE) && (conn_callback_func.update_conn_param_cb != NULL)) {
|
||||
tBTM_LE_UPDATE_CONN_PRAMS update_param;
|
||||
update_param.max_conn_int = max_int;
|
||||
update_param.min_conn_int = min_int;
|
||||
update_param.conn_int = p_lcb->current_used_conn_interval;
|
||||
update_param.slave_latency = p_lcb->current_used_conn_latency;
|
||||
update_param.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
(conn_callback_func.update_conn_param_cb)(status, p_lcb->remote_bd_addr, &update_param);
|
||||
if (need_cb) {
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.conn_params_update.status = status;
|
||||
memcpy(cb_params.conn_params_update.remote_bd_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
|
||||
cb_params.conn_params_update.min_conn_int = min_int;
|
||||
cb_params.conn_params_update.max_conn_int = max_int;
|
||||
cb_params.conn_params_update.conn_int = p_lcb->current_used_conn_interval;
|
||||
cb_params.conn_params_update.slave_latency = p_lcb->current_used_conn_latency;
|
||||
cb_params.conn_params_update.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_CONNECTION_PARAMS_UPDATE_EVT, &cb_params);
|
||||
|
||||
return (status == HCI_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -234,6 +239,7 @@ BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable)
|
||||
return (FALSE);
|
||||
}
|
||||
bool is_disable = (p_lcb->conn_update_mask & L2C_BLE_CONN_UPDATE_DISABLE);
|
||||
// for multiple links, actively updating the parameters to 7.5ms may degrade multi-connection performance
|
||||
if(l2cu_ble_plcb_active_count() >1 && !(enable && is_disable)) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -646,9 +652,8 @@ void l2cble_process_conn_update_evt (UINT16 handle, UINT8 status, UINT16 conn_in
|
||||
p_lcb->conn_update_mask &= ~L2C_BLE_UPDATE_PARAM_FULL;
|
||||
btu_stop_timer(&p_lcb->upda_con_timer);
|
||||
|
||||
if (conn_callback_func.update_conn_param_cb != NULL) {
|
||||
l2c_send_update_conn_params_cb(p_lcb, status);
|
||||
}
|
||||
|
||||
l2c_send_update_conn_params_cb(p_lcb, status);
|
||||
|
||||
if (l2cble_start_conn_update(p_lcb) == TRUE) {
|
||||
UINT32 time = CalConnectParamTimeout(p_lcb);
|
||||
@@ -685,9 +690,8 @@ void l2cble_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handl
|
||||
|
||||
btu_stop_timer (&p_lcb->upda_con_timer);
|
||||
|
||||
if (conn_callback_func.update_conn_param_cb != NULL) {
|
||||
l2c_send_update_conn_params_cb(p_lcb, status);
|
||||
}
|
||||
l2c_send_update_conn_params_cb(p_lcb, status);
|
||||
|
||||
if ((p_lcb->conn_update_mask & L2C_BLE_UPDATE_PARAM_FULL) != 0){
|
||||
p_lcb->conn_update_mask &= ~L2C_BLE_UPDATE_PARAM_FULL;
|
||||
if (l2cble_start_conn_update(p_lcb) == TRUE) {
|
||||
@@ -827,7 +831,6 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
STREAM_TO_UINT16(mps, p);
|
||||
STREAM_TO_UINT16(credits, p);
|
||||
L2CAP_TRACE_DEBUG("%s spsm %x, scid %x", __func__, spsm, scid);
|
||||
UNUSED(spsm);
|
||||
|
||||
p_ccb = l2cu_find_ccb_by_remote_cid(p_lcb, scid);
|
||||
if (p_ccb) {
|
||||
@@ -835,12 +838,11 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0
|
||||
p_rcb = l2cu_find_ble_rcb_by_psm(spsm);
|
||||
if (p_rcb == NULL) {
|
||||
l2cu_reject_ble_connection(p_lcb, id, L2CAP_LE_RESULT_NO_PSM);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
p_ccb = l2cu_allocate_ccb(p_lcb, 0);
|
||||
if (p_ccb == NULL) {
|
||||
@@ -861,6 +863,34 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
l2cu_send_peer_ble_credit_based_conn_res(p_ccb, L2CAP_LE_RESULT_CONN_OK);
|
||||
break;
|
||||
}
|
||||
case L2CAP_CMD_BLE_FLOW_CTRL_CREDIT: {
|
||||
if (cmd_len < L2CAP_CMD_BLE_FLOW_CTRL_CREDIT_LEN) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - LE - flow ctrl credit too short: %d", cmd_len);
|
||||
return;
|
||||
}
|
||||
tL2C_CCB *p_ccb = NULL;
|
||||
UINT16 lcid;
|
||||
UINT16 credit;
|
||||
STREAM_TO_UINT16(lcid, p);
|
||||
STREAM_TO_UINT16(credit, p);
|
||||
|
||||
p_ccb = l2cu_find_ccb_by_cid(p_lcb, lcid);
|
||||
if (p_ccb == NULL) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - LE - flow ctrl credit for unknown CID: 0x%04x", lcid);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((p_ccb->peer_conn_cfg.credits + credit) > L2CAP_LE_MAX_CREDIT) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - LE - credit overflow, disconnecting CID: 0x%04x", lcid);
|
||||
l2cble_send_peer_disc_req(p_ccb);
|
||||
} else {
|
||||
p_ccb->peer_conn_cfg.credits += credit;
|
||||
L2CAP_TRACE_DEBUG ("L2CAP - LE - credits updated to %d for CID: 0x%04x",
|
||||
p_ccb->peer_conn_cfg.credits, lcid);
|
||||
l2c_link_check_send_pkts(p_ccb->p_lcb, NULL, NULL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case L2CAP_CMD_DISC_REQ: {
|
||||
if (cmd_len < 4) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - LE - short cmd: %d", cmd_len);
|
||||
@@ -875,10 +905,11 @@ void l2cble_process_sig_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
p_ccb = l2cu_find_ccb_by_cid(p_lcb, lcid);
|
||||
if (p_ccb) {
|
||||
p_ccb->remote_id = id;
|
||||
// TODO
|
||||
l2cu_send_peer_disc_rsp(p_lcb, id, lcid, rcid);
|
||||
} else {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - LE - disc req with invalid lcid, send cmd reject");
|
||||
l2cu_send_peer_cmd_reject(p_lcb, L2CAP_CMD_REJ_INVALID_CID, id, rcid, lcid);
|
||||
}
|
||||
|
||||
l2cu_send_peer_disc_rsp(p_lcb, id, lcid, rcid);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -986,13 +1017,20 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
|
||||
uint32_t link_timeout = L2CAP_BLE_LINK_CONNECT_TOUT;
|
||||
if(GATTC_CONNECT_RETRY_COUNT) {
|
||||
if(!p_lcb->retry_create_con) {
|
||||
p_lcb->start_time_s = (esp_system_get_time()/1000);
|
||||
p_lcb->start_time_s = esp_system_get_time() / 1000;
|
||||
}
|
||||
uint32_t current_time = (esp_system_get_time()/1000);
|
||||
link_timeout = (L2CAP_BLE_LINK_CONNECT_TOUT*1000 - (current_time - p_lcb->start_time_s))/1000;
|
||||
int64_t current_time = esp_system_get_time() / 1000;
|
||||
int64_t elapsed_ms = current_time - p_lcb->start_time_s;
|
||||
int64_t timeout_ms = (int64_t)L2CAP_BLE_LINK_CONNECT_TOUT * 1000;
|
||||
int64_t remaining_ms = timeout_ms - elapsed_ms;
|
||||
|
||||
if(link_timeout == 0 || link_timeout > L2CAP_BLE_LINK_CONNECT_TOUT) {
|
||||
if (remaining_ms <= 0 || remaining_ms > timeout_ms) {
|
||||
link_timeout = L2CAP_BLE_LINK_CONNECT_TOUT;
|
||||
} else {
|
||||
link_timeout = (uint32_t)(remaining_ms / 1000);
|
||||
if (link_timeout == 0) {
|
||||
link_timeout = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,19 +1111,29 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb)
|
||||
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
if (p_lcb->is_pawr_synced) {
|
||||
if(!btsnd_hcic_ble_create_ext_conn_v2(&aux_conn)) {
|
||||
l2cb.is_ble_connecting = FALSE;
|
||||
memset(l2cb.ble_connecting_bda, 0, BD_ADDR_LEN);
|
||||
btm_ble_set_conn_st (BLE_CONN_IDLE);
|
||||
l2cu_release_lcb (p_lcb);
|
||||
L2CAP_TRACE_ERROR("initiate pawr sync connection failed, no resources");
|
||||
return (FALSE);
|
||||
}
|
||||
} else
|
||||
#endif // (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
{
|
||||
if(!btsnd_hcic_ble_create_ext_conn(&aux_conn)) {
|
||||
l2cb.is_ble_connecting = FALSE;
|
||||
memset(l2cb.ble_connecting_bda, 0, BD_ADDR_LEN);
|
||||
btm_ble_set_conn_st (BLE_CONN_IDLE);
|
||||
l2cu_release_lcb (p_lcb);
|
||||
L2CAP_TRACE_ERROR("initiate Aux connection failed, no resources");
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
#else
|
||||
l2cu_release_lcb (p_lcb);
|
||||
L2CAP_TRACE_ERROR("BLE 5.0 not support!\n");
|
||||
return (FALSE);
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
return (TRUE);
|
||||
}
|
||||
@@ -1293,7 +1341,7 @@ void l2cble_process_rc_param_request_evt(UINT16 handle, UINT16 int_min, UINT16 i
|
||||
btsnd_hcic_ble_rc_param_req_reply(handle, int_min, int_max, latency, timeout, BLE_CE_LEN_MIN, BLE_CE_LEN_MIN);
|
||||
}else {
|
||||
L2CAP_TRACE_EVENT ("L2CAP - LE - update currently disabled");
|
||||
p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
|
||||
// p_lcb->conn_update_mask |= L2C_BLE_NEW_CONN_PARAM;
|
||||
btsnd_hcic_ble_rc_param_req_neg_reply (handle, HCI_ERR_UNACCEPT_CONN_INTERVAL);
|
||||
}
|
||||
}
|
||||
@@ -1374,23 +1422,24 @@ void l2cble_process_data_length_change_event(UINT16 handle, UINT16 tx_data_len,
|
||||
|
||||
if(p_acl) {
|
||||
p_acl->data_length_params = data_length_params;
|
||||
if (p_acl->p_set_pkt_data_cback) {
|
||||
// Only when the corresponding API is called will the callback be registered
|
||||
(*p_acl->p_set_pkt_data_cback)(BTM_SUCCESS, &data_length_params);
|
||||
} else {
|
||||
// If the callback is not registered,using global callback
|
||||
(*conn_callback_func.set_pkt_data_length_cb)(BTM_SUCCESS, &data_length_params);
|
||||
}
|
||||
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.data_length_params.status = BTM_SUCCESS;
|
||||
cb_params.data_length_params.rx_len = data_length_params.rx_len;
|
||||
cb_params.data_length_params.tx_len = data_length_params.tx_len;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_DATA_LEN_SET_COMPLETE_EVT, &cb_params);
|
||||
|
||||
p_acl->data_len_updating = false;
|
||||
if(p_acl->data_len_waiting) {
|
||||
p_acl->data_len_waiting = false;
|
||||
p_acl->p_set_pkt_data_cback = p_acl->p_set_data_len_cback_waiting;
|
||||
p_acl->p_set_data_len_cback_waiting = NULL;
|
||||
// if value is same, trigger callback directly
|
||||
if(p_acl->tx_len_waiting == p_acl->data_length_params.tx_len) {
|
||||
if(p_acl->p_set_pkt_data_cback) {
|
||||
(*p_acl->p_set_pkt_data_cback)(BTM_SUCCESS, &p_acl->data_length_params);
|
||||
}
|
||||
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
cb_params.data_length_params.status = BTM_SUCCESS;
|
||||
cb_params.data_length_params.rx_len = data_length_params.rx_len;
|
||||
cb_params.data_length_params.tx_len = data_length_params.tx_len;
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_DATA_LEN_SET_COMPLETE_EVT, &cb_params);
|
||||
return;
|
||||
}
|
||||
p_acl->data_len_updating = true;
|
||||
@@ -1450,24 +1499,26 @@ void l2cble_set_fixed_channel_tx_data_length(BD_ADDR remote_bda, UINT16 fix_cid,
|
||||
*******************************************************************************/
|
||||
void l2c_send_update_conn_params_cb(tL2C_LCB *p_lcb, UINT8 status)
|
||||
{
|
||||
if(conn_callback_func.update_conn_param_cb != NULL){
|
||||
tBTM_LE_UPDATE_CONN_PRAMS update_param;
|
||||
//if myself update the connection parameters
|
||||
if (p_lcb->updating_param_flag){
|
||||
update_param.max_conn_int = p_lcb->updating_conn_max_interval;
|
||||
update_param.min_conn_int = p_lcb->updating_conn_min_interval;
|
||||
p_lcb->updating_param_flag = false;
|
||||
}else{
|
||||
// remote device update the connection parameters
|
||||
update_param.max_conn_int = update_param.min_conn_int = 0;
|
||||
}
|
||||
// current connection parameters
|
||||
update_param.conn_int = p_lcb->current_used_conn_interval;
|
||||
update_param.slave_latency = p_lcb->current_used_conn_latency;
|
||||
update_param.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
|
||||
(conn_callback_func.update_conn_param_cb)(status, p_lcb->remote_bd_addr, &update_param);
|
||||
tBTM_BLE_LEGACY_GAP_CB_PARAMS cb_params = {0};
|
||||
//if myself update the connection parameters
|
||||
if (p_lcb->updating_param_flag){
|
||||
cb_params.conn_params_update.max_conn_int = p_lcb->updating_conn_max_interval;
|
||||
cb_params.conn_params_update.min_conn_int = p_lcb->updating_conn_min_interval;
|
||||
p_lcb->updating_param_flag = false;
|
||||
}else{
|
||||
// remote device update the connection parameters
|
||||
cb_params.conn_params_update.max_conn_int = cb_params.conn_params_update.min_conn_int = 0;
|
||||
}
|
||||
// current connection parameters
|
||||
cb_params.conn_params_update.conn_int = p_lcb->current_used_conn_interval;
|
||||
cb_params.conn_params_update.slave_latency = p_lcb->current_used_conn_latency;
|
||||
cb_params.conn_params_update.supervision_tout = p_lcb->current_used_conn_timeout;
|
||||
|
||||
|
||||
cb_params.conn_params_update.status = status;
|
||||
memcpy(cb_params.conn_params_update.remote_bd_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
|
||||
|
||||
BTM_LegacyBleCallbackTrigger(BTM_BLE_LEGACY_GAP_CONNECTION_PARAMS_UPDATE_EVT, &cb_params);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf);
|
||||
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
extern tBTM_STATUS BTM_BleStartExtAdvRestart(uint8_t handle);
|
||||
extern tBTM_STATUS BTM_BleStartExtAdvRestart(uint16_t handle);
|
||||
#endif// #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
extern bool btm_ble_inter_get(void);
|
||||
|
||||
@@ -379,6 +379,9 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
} else {
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tL2C_LINK_STATE link_state_temp = p_lcb->link_state;
|
||||
#if ((BLE_42_ADV_EN == TRUE) || (GATTC_CONNECT_RETRY_EN == TRUE) || (BLE_50_EXTEND_ADV_EN == TRUE))
|
||||
UINT8 link_role_temp = p_lcb->link_role;
|
||||
#endif
|
||||
#endif // (BLE_INCLUDED == TRUE)
|
||||
/* There can be a case when we rejected PIN code authentication */
|
||||
/* otherwise save a new reason */
|
||||
@@ -469,6 +472,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/* l2cu_create_conn must not release the LCB on failure */
|
||||
if (l2cu_create_conn(p_lcb, transport)) {
|
||||
lcb_is_free = FALSE; /* still using this lcb */
|
||||
}
|
||||
@@ -476,13 +480,15 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
|
||||
p_lcb->p_pending_ccb = NULL;
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
if(p_lcb->transport == BT_TRANSPORT_LE) {
|
||||
/* Use p_lcb->transport so BLE reconnection (slave adv restart / master retry) runs even when
|
||||
* there was no pending CCB; 'transport' is only set when (p_first_ccb || p_pending_ccb). */
|
||||
if (p_lcb->transport == BT_TRANSPORT_LE) {
|
||||
// for legacy adv, adv restart in gatt_le_connect_cback->gatt_cleanup_upon_disc->BTM_Recovery_Pre_State
|
||||
if (reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) {
|
||||
|
||||
#if (BLE_42_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_42_ADV_EN == TRUE)
|
||||
if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||
if(!btm_ble_inter_get() && link_role_temp == HCI_ROLE_SLAVE) {
|
||||
L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
tBTM_STATUS start_adv_status = btm_ble_start_adv();
|
||||
if (start_adv_status != BTM_SUCCESS) {
|
||||
@@ -496,7 +502,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
if ((reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) || (link_state_temp == LST_CONNECTING)) {
|
||||
|
||||
#if (GATTC_CONNECT_RETRY_EN == TRUE)
|
||||
if(p_lcb->link_role == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||
if(link_role_temp == HCI_ROLE_MASTER && p_lcb->retry_create_con < GATTC_CONNECT_RETRY_COUNT) {
|
||||
L2CAP_TRACE_DEBUG("master retry connect, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
p_lcb->retry_create_con ++;
|
||||
// create connection retry
|
||||
@@ -513,7 +519,7 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason)
|
||||
if ((reason == HCI_ERR_CONN_FAILED_ESTABLISHMENT) || (link_state_temp == LST_DISCONNECTED)) {
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_50_EXTEND_ADV_EN == TRUE)
|
||||
if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) {
|
||||
if(btm_ble_inter_get() && link_role_temp == HCI_ROLE_SLAVE) {
|
||||
L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason);
|
||||
tBTM_STATUS start_adv_status = BTM_BleStartExtAdvRestart(handle);
|
||||
if (start_adv_status != BTM_SUCCESS) {
|
||||
@@ -626,6 +632,7 @@ void l2c_link_timeout (tL2C_LCB *p_lcb)
|
||||
#endif
|
||||
/* Release the LCB */
|
||||
l2cu_release_lcb (p_lcb);
|
||||
return;
|
||||
}
|
||||
|
||||
/* If link is connected, check for inactivity timeout */
|
||||
@@ -1314,6 +1321,13 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf)
|
||||
acl_data_size = controller->get_acl_data_size_classic();
|
||||
xmit_window = l2cb.controller_xmit_window;
|
||||
}
|
||||
|
||||
if (p_buf->len <= HCI_DATA_PREAMBLE_SIZE) {
|
||||
L2CAP_TRACE_ERROR ("l2c_link_send_to_lower - bad buffer len: %u", p_buf->len);
|
||||
osi_free(p_buf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
num_segs = (p_buf->len - HCI_DATA_PREAMBLE_SIZE + acl_data_size - 1) / acl_data_size;
|
||||
|
||||
|
||||
@@ -1395,15 +1409,26 @@ static BOOLEAN l2c_link_send_to_lower (tL2C_LCB *p_lcb, BT_HDR *p_buf)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void l2c_link_process_num_completed_pkts (UINT8 *p)
|
||||
void l2c_link_process_num_completed_pkts (UINT8 *p, UINT8 evt_len)
|
||||
{
|
||||
UINT8 num_handles, xx;
|
||||
UINT16 handle;
|
||||
UINT16 num_sent;
|
||||
tL2C_LCB *p_lcb;
|
||||
|
||||
if (evt_len < 1) {
|
||||
L2CAP_TRACE_ERROR ("l2c_link_process_num_completed_pkts: evt too short (len=%u)", evt_len);
|
||||
return;
|
||||
}
|
||||
|
||||
STREAM_TO_UINT8 (num_handles, p);
|
||||
|
||||
if (num_handles > (evt_len - 1) / 4) {
|
||||
L2CAP_TRACE_ERROR ("l2c_link_process_num_completed_pkts: num_handles %u exceeds evt_len %u, truncating",
|
||||
num_handles, evt_len);
|
||||
num_handles = (evt_len - 1) / 4;
|
||||
}
|
||||
|
||||
for (xx = 0; xx < num_handles; xx++) {
|
||||
STREAM_TO_UINT16 (handle, p);
|
||||
STREAM_TO_UINT16 (num_sent, p);
|
||||
|
||||
@@ -150,7 +150,6 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
#if (!CONFIG_BT_STACK_NO_LOG)
|
||||
UINT16 psm;
|
||||
#endif
|
||||
UINT16 credit;
|
||||
|
||||
/* Extract the handle */
|
||||
STREAM_TO_UINT16 (handle, p);
|
||||
@@ -292,6 +291,9 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE) {
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
l2c_fcr_proc_pdu (p_ccb, p_msg);
|
||||
#else
|
||||
/* Classic FCR not compiled (e.g. BLE-only); free p_msg to avoid leak */
|
||||
osi_free (p_msg);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
} else {
|
||||
(*l2cb.fixed_reg[rcv_cid - L2CAP_FIRST_FIXED_CHNL].pL2CA_FixedData_Cb)
|
||||
@@ -310,31 +312,24 @@ void l2c_rcv_acl_data (BT_HDR *p_msg)
|
||||
osi_free (p_msg);
|
||||
} else {
|
||||
if (p_lcb->transport == BT_TRANSPORT_LE) {
|
||||
// Got a pkt, valid send out credits to the peer device
|
||||
credit = L2CAP_LE_DEFAULT_CREDIT;
|
||||
L2CAP_TRACE_DEBUG("%s Credits received %d",__func__, credit);
|
||||
if((p_ccb->peer_conn_cfg.credits + credit) > L2CAP_LE_MAX_CREDIT) {
|
||||
/* we have received credits more than max coc credits,
|
||||
* so disconnecting the Le Coc Channel
|
||||
*/
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
l2cble_send_peer_disc_req (p_ccb);
|
||||
#endif ///BLE_INCLUDED == TRUE
|
||||
} else {
|
||||
p_ccb->peer_conn_cfg.credits += credit;
|
||||
l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
|
||||
}
|
||||
l2c_link_check_send_pkts (p_ccb->p_lcb, NULL, NULL);
|
||||
}
|
||||
/* Basic mode packets go straight to the state machine */
|
||||
if (p_ccb->peer_cfg.fcr.mode == L2CAP_FCR_BASIC_MODE) {
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
#if (L2CAP_COC_INCLUDED == TRUE)
|
||||
l2c_csm_execute (p_ccb, L2CEVT_L2CAP_DATA, p_msg);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
#else
|
||||
/* COC not included: state machine not compiled; free p_msg to avoid leak */
|
||||
osi_free (p_msg);
|
||||
#endif
|
||||
} else {
|
||||
/* eRTM or streaming mode, so we need to validate states first */
|
||||
if ((p_ccb->chnl_state == CST_OPEN) || (p_ccb->chnl_state == CST_CONFIG)) {
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
l2c_fcr_proc_pdu (p_ccb, p_msg);
|
||||
#else
|
||||
/* Classic FCR not compiled (e.g. BLE-only); free p_msg to avoid leak */
|
||||
osi_free (p_msg);
|
||||
#endif ///CLASSIC_BT_INCLUDED == TRUE
|
||||
} else {
|
||||
osi_free (p_msg);
|
||||
@@ -423,14 +418,26 @@ static void process_l2cap_cmd (tL2C_LCB *p_lcb, UINT8 *p, UINT16 pkt_len)
|
||||
|
||||
switch (cmd_code) {
|
||||
case L2CAP_CMD_REJECT:
|
||||
if (cmd_len < L2CAP_CMD_REJECT_LEN) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - cmd reject too short, cmd_len: %d", cmd_len);
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT16 (rej_reason, p);
|
||||
if (rej_reason == L2CAP_CMD_REJ_MTU_EXCEEDED) {
|
||||
if (cmd_len < L2CAP_CMD_REJECT_LEN + 2) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - MTU rej too short, cmd_len: %d", cmd_len);
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT16 (rej_mtu, p);
|
||||
/* What to do with the MTU reject ? We have negotiated an MTU. For now */
|
||||
/* we will ignore it and let a higher protocol timeout take care of it */
|
||||
L2CAP_TRACE_WARNING ("L2CAP - MTU rej Handle: %d MTU: %d", p_lcb->handle, rej_mtu);
|
||||
}
|
||||
if (rej_reason == L2CAP_CMD_REJ_INVALID_CID) {
|
||||
if (cmd_len < L2CAP_CMD_REJECT_LEN + 4) {
|
||||
L2CAP_TRACE_WARNING ("L2CAP - CID rej too short, cmd_len: %d", cmd_len);
|
||||
break;
|
||||
}
|
||||
STREAM_TO_UINT16 (rcid, p);
|
||||
STREAM_TO_UINT16 (lcid, p);
|
||||
|
||||
@@ -909,7 +916,7 @@ void l2c_init (void)
|
||||
l2cb.l2c_ble_fixed_chnls_mask =
|
||||
L2CAP_FIXED_CHNL_ATT_BIT | L2CAP_FIXED_CHNL_BLE_SIG_BIT | L2CAP_FIXED_CHNL_SMP_BIT;
|
||||
#endif
|
||||
|
||||
// Free callback must be NULL
|
||||
l2cb.rcv_pending_q = list_new(NULL);
|
||||
if (l2cb.rcv_pending_q == NULL) {
|
||||
L2CAP_TRACE_ERROR("%s unable to allocate memory for link layer control block", __func__);
|
||||
@@ -948,6 +955,10 @@ void l2c_free_p_ccb_pool(void)
|
||||
|
||||
void l2c_free(void)
|
||||
{
|
||||
// check again
|
||||
if (l2cb.rcv_pending_q && list_length(l2cb.rcv_pending_q) > 0) {
|
||||
assert(0);
|
||||
}
|
||||
list_free(l2cb.rcv_pending_q);
|
||||
l2cb.rcv_pending_q = NULL;
|
||||
l2c_free_p_lcb_pool();
|
||||
|
||||
@@ -170,6 +170,10 @@ void l2cu_release_lcb (tL2C_LCB *p_lcb)
|
||||
p_lcb->start_time_s = 0;
|
||||
#endif // #if (BLE_INCLUDED == TRUE)
|
||||
|
||||
#if (BT_BLE_FEAT_PAWR_EN == TRUE)
|
||||
p_lcb->is_pawr_synced = FALSE;
|
||||
#endif
|
||||
|
||||
/* Stop and release timers */
|
||||
btu_free_timer (&p_lcb->timer_entry);
|
||||
memset(&p_lcb->timer_entry, 0, sizeof(TIMER_LIST_ENT));
|
||||
@@ -364,10 +368,7 @@ uint8_t l2cu_ble_plcb_active_count(void)
|
||||
active_count ++;
|
||||
}
|
||||
}
|
||||
if (active_count >= MAX_L2CAP_CHANNELS) {
|
||||
L2CAP_TRACE_ERROR("error active count");
|
||||
active_count = 0;
|
||||
}
|
||||
|
||||
L2CAP_TRACE_DEBUG("plcb active count %d", active_count);
|
||||
return active_count;
|
||||
|
||||
@@ -1898,15 +1899,31 @@ void l2cu_disconnect_chnl (tL2C_CCB *p_ccb)
|
||||
UINT16 local_cid = p_ccb->local_cid;
|
||||
|
||||
if (local_cid >= L2CAP_BASE_APPL_CID) {
|
||||
tL2CA_DISCONNECT_IND_CB *p_disc_cb = p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
|
||||
tL2CA_DISCONNECT_IND_CB *p_disc_cb = NULL;
|
||||
|
||||
if (p_ccb->p_rcb != NULL) {
|
||||
p_disc_cb = p_ccb->p_rcb->api.pL2CA_DisconnectInd_Cb;
|
||||
}
|
||||
|
||||
L2CAP_TRACE_WARNING ("L2CAP - disconnect_chnl CID: 0x%04x", local_cid);
|
||||
|
||||
l2cu_send_peer_disc_req (p_ccb);
|
||||
|
||||
/*
|
||||
* l2cu_send_peer_disc_req drains xmit_hold_q in basic FCR mode.
|
||||
* Free the queue and NULL it here to prevent l2cu_release_ccb from
|
||||
* calling fixed_queue_free again on already-dequeued buffers.
|
||||
*/
|
||||
if (p_ccb->xmit_hold_q != NULL) {
|
||||
fixed_queue_free(p_ccb->xmit_hold_q, osi_free_func);
|
||||
p_ccb->xmit_hold_q = NULL;
|
||||
}
|
||||
|
||||
l2cu_release_ccb (p_ccb);
|
||||
|
||||
(*p_disc_cb)(local_cid, FALSE);
|
||||
if (p_disc_cb) {
|
||||
(*p_disc_cb)(local_cid, FALSE);
|
||||
}
|
||||
} else {
|
||||
/* failure on the AMP channel, probably need to disconnect ACL */
|
||||
L2CAP_TRACE_ERROR ("L2CAP - disconnect_chnl CID: 0x%04x Ignored", local_cid);
|
||||
@@ -3286,7 +3303,7 @@ tL2C_LCB *l2cu_find_lcb_by_handle (UINT16 handle)
|
||||
bool l2cu_find_ccb_in_list(void *p_ccb_node, void *p_local_cid)
|
||||
{
|
||||
tL2C_CCB *p_ccb = (tL2C_CCB *)p_ccb_node;
|
||||
uint8_t local_cid = *((uint8_t *)p_local_cid);
|
||||
uint16_t local_cid = *((uint16_t *)p_local_cid);
|
||||
|
||||
if (p_ccb->local_cid == local_cid && p_ccb->in_use) {
|
||||
return FALSE;
|
||||
|
||||
@@ -510,7 +510,7 @@ extern void smp_generate_passkey (tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_generate_rand_cont(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_create_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_use_oob_private_key(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
extern void smp_compute_dhkey(tSMP_CB *p_cb);
|
||||
extern BOOLEAN smp_compute_dhkey(tSMP_CB *p_cb);
|
||||
extern void smp_calculate_local_commitment(tSMP_CB *p_cb);
|
||||
extern void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf);
|
||||
extern void smp_calculate_numeric_comparison_display_number(tSMP_CB *p_cb, tSMP_INT_DATA *p_data);
|
||||
|
||||
@@ -177,9 +177,16 @@ static void ECC_NAF(uint8_t *naf, uint32_t *NumNAF, DWORD *k, uint32_t keyLength
|
||||
k[0] = k[0] + 1;
|
||||
if (k[0] == 0) { //overflow
|
||||
j = 1;
|
||||
do {
|
||||
while (j < keyLength && k[j] == 0xFFFFFFFF) {
|
||||
k[j] = 0;
|
||||
j++;
|
||||
}
|
||||
if (j < keyLength) {
|
||||
k[j]++;
|
||||
} while (k[j++] == 0); //overflow
|
||||
}
|
||||
// If j >= keyLength, the entire key is 0xFFFFFFFF,
|
||||
// which should not happen for a valid private key.
|
||||
// In this case, we stop the propagation to prevent buffer overflow.
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -267,7 +274,9 @@ bool ECC_CheckPointIsInElliCur_P256(Point *p)
|
||||
/* The function of the elliptic curve is y^2 = x^3 - 3x + b (mod q) ==>
|
||||
y^2 = (x^2 - 3)*x + b (mod q),
|
||||
so we calculate the x^2 - 3 value here */
|
||||
x_x[0] -= 3;
|
||||
DWORD three[2 * KEY_LENGTH_DWORDS_P256] = {0};
|
||||
three[0] = 3;
|
||||
multiprecision_sub(x_x, x_x, three, 2 * KEY_LENGTH_DWORDS_P256);
|
||||
/* Using math relations. (a*b) % q = ((a%q)*(b%q)) % q ==>
|
||||
(x^2 - 3)*x = (((x^2 - 3) % q) * x % q) % q */
|
||||
multiprecision_fast_mod_P256(x_x_q, x_x);
|
||||
|
||||
@@ -262,7 +262,7 @@ void multiprecision_mult(DWORD *c, DWORD *a, DWORD *b, uint32_t keyLength)
|
||||
DWORD V;
|
||||
|
||||
U = V = W = 0;
|
||||
multiprecision_init(c, keyLength);
|
||||
multiprecision_init(c, 2 * keyLength);
|
||||
|
||||
//assume little endian right now
|
||||
for (uint32_t i = 0; i < keyLength; i++) {
|
||||
@@ -340,7 +340,7 @@ void multiprecision_fast_mod(DWORD *c, DWORD *a)
|
||||
c[2] += V;
|
||||
V = c[2] < V;
|
||||
c[2] += U;
|
||||
V = c[2] < U;
|
||||
V += c[2] < U;
|
||||
c[3] += V;
|
||||
V = c[3] < V;
|
||||
c[4] += V;
|
||||
@@ -594,6 +594,7 @@ void multiprecision_fast_mod_P256(DWORD *c, DWORD *a)
|
||||
|
||||
void multiprecision_inv_mod(DWORD *aminus, DWORD *u, uint32_t keyLength)
|
||||
{
|
||||
DWORD u_local[KEY_LENGTH_DWORDS_P256];
|
||||
DWORD v[KEY_LENGTH_DWORDS_P256];
|
||||
DWORD A[KEY_LENGTH_DWORDS_P256 + 1];
|
||||
DWORD C[KEY_LENGTH_DWORDS_P256 + 1];
|
||||
@@ -605,14 +606,15 @@ void multiprecision_inv_mod(DWORD *aminus, DWORD *u, uint32_t keyLength)
|
||||
modp = curve.p;
|
||||
}
|
||||
|
||||
multiprecision_copy(u_local, u, keyLength);
|
||||
multiprecision_copy(v, modp, keyLength);
|
||||
multiprecision_init(A, keyLength);
|
||||
multiprecision_init(C, keyLength);
|
||||
A[0] = 1;
|
||||
|
||||
while (!multiprecision_iszero(u, keyLength)) {
|
||||
while (!(u[0] & 0x01)) { // u is even
|
||||
multiprecision_rshift(u, u, keyLength);
|
||||
while (!multiprecision_iszero(u_local, keyLength)) {
|
||||
while (!(u_local[0] & 0x01)) { // u is even
|
||||
multiprecision_rshift(u_local, u_local, keyLength);
|
||||
if (!(A[0] & 0x01)) { // A is even
|
||||
multiprecision_rshift(A, A, keyLength);
|
||||
} else {
|
||||
@@ -633,11 +635,11 @@ void multiprecision_inv_mod(DWORD *aminus, DWORD *u, uint32_t keyLength)
|
||||
}
|
||||
}
|
||||
|
||||
if (multiprecision_compare(u, v, keyLength) >= 0) {
|
||||
multiprecision_sub(u, u, v, keyLength);
|
||||
if (multiprecision_compare(u_local, v, keyLength) >= 0) {
|
||||
multiprecision_sub(u_local, u_local, v, keyLength);
|
||||
multiprecision_sub_mod(A, A, C, keyLength);
|
||||
} else {
|
||||
multiprecision_sub(v, v, u, keyLength);
|
||||
multiprecision_sub(v, v, u_local, keyLength);
|
||||
multiprecision_sub_mod(C, C, A, keyLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,7 +406,7 @@ void smp_send_id_info(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
smp_send_cmd(SMP_OPCODE_ID_ADDR, p_cb);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
tBTM_LE_KEY_VALUE le_key;
|
||||
tBTM_LE_KEY_VALUE le_key = {0};
|
||||
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,
|
||||
&le_key, TRUE);
|
||||
@@ -1440,7 +1440,9 @@ void smp_key_distribution(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
if (smp_get_state() == SMP_STATE_BOND_PENDING) {
|
||||
if (p_cb->derive_lk) {
|
||||
tBTM_SEC_DEV_REC* p_dev_rec = btm_find_dev(p_cb->pairing_bda);
|
||||
if (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) &&
|
||||
if (p_dev_rec == NULL) {
|
||||
SMP_TRACE_WARNING("%s device record not found, skip LK derivation", __func__);
|
||||
} else if (!(p_dev_rec->sec_flags & BTM_SEC_LE_LINK_KEY_AUTHED) &&
|
||||
(p_dev_rec->sec_flags & BTM_SEC_LINK_KEY_AUTHED)) {
|
||||
SMP_TRACE_DEBUG("%s BREDR key is higher security than existing LE keys, "
|
||||
"don't derive LK from LTK", __func__);
|
||||
@@ -1698,7 +1700,11 @@ void smp_both_have_public_keys(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
|
||||
/* invokes DHKey computation */
|
||||
smp_compute_dhkey(p_cb);
|
||||
if (!smp_compute_dhkey(p_cb)) {
|
||||
UINT8 reason = SMP_PAIR_INTERNAL_ERR;
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
|
||||
return;
|
||||
}
|
||||
|
||||
/* on slave side invokes sending local public key to the peer */
|
||||
if (p_cb->role == HCI_ROLE_SLAVE) {
|
||||
|
||||
@@ -483,6 +483,10 @@ void SMP_SecureConnectionOobDataReply(UINT8 *p_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_cb->state != SMP_STATE_WAIT_APP_RSP || p_cb->cb_evt != SMP_SC_OOB_REQ_EVT) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set local oob data when req_oob_type = SMP_OOB_BOTH */
|
||||
memcpy(&p_oob->loc_oob_data, smp_get_local_oob_data(), sizeof(tSMP_LOC_OOB_DATA));
|
||||
|
||||
@@ -491,10 +495,6 @@ void SMP_SecureConnectionOobDataReply(UINT8 *p_data)
|
||||
__FUNCTION__, p_cb->req_oob_type, p_oob->loc_oob_data.present,
|
||||
p_oob->peer_oob_data.present);
|
||||
|
||||
if (p_cb->state != SMP_STATE_WAIT_APP_RSP || p_cb->cb_evt != SMP_SC_OOB_REQ_EVT) {
|
||||
return;
|
||||
}
|
||||
|
||||
BOOLEAN data_missing = FALSE;
|
||||
switch (p_cb->req_oob_type) {
|
||||
case SMP_OOB_PEER:
|
||||
|
||||
@@ -154,6 +154,11 @@ static BOOLEAN cmac_aes_k_calculate(BT_OCTET16 key, UINT8 *p_signature, UINT16 t
|
||||
|
||||
SMP_TRACE_EVENT ("cmac_aes_k_calculate ");
|
||||
|
||||
if (cmac_cb.round == 0) {
|
||||
SMP_TRACE_ERROR("%s round is 0", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while (i <= cmac_cb.round) {
|
||||
smp_xor_128(&cmac_cb.text[(cmac_cb.round - i)*BT_OCTET16_LEN], x); /* Mi' := Mi (+) X */
|
||||
|
||||
@@ -305,6 +310,11 @@ BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 length,
|
||||
|
||||
SMP_TRACE_EVENT ("%s", __func__);
|
||||
|
||||
if (tlen == 0 || tlen > BT_OCTET16_LEN) {
|
||||
SMP_TRACE_ERROR("%s invalid tlen=%d", __func__, tlen);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if (SMP_CRYPTO_MBEDTLS == TRUE)
|
||||
{
|
||||
/*
|
||||
|
||||
@@ -629,10 +629,10 @@ void smp_concatenate_peer( tSMP_CB *p_cb, UINT8 **p_data, UINT8 op_code)
|
||||
** Description Generate Confirm/Compare Step1:
|
||||
** p1 = press || preq || rat' || iat'
|
||||
**
|
||||
** Returns void
|
||||
** Returns BOOLEAN
|
||||
**
|
||||
*******************************************************************************/
|
||||
void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
|
||||
BOOLEAN smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
|
||||
{
|
||||
UINT8 *p = (UINT8 *)p1;
|
||||
tBLE_ADDR_TYPE addr_type = 0;
|
||||
@@ -642,7 +642,7 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
|
||||
|
||||
if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, remote_bda, &addr_type)) {
|
||||
SMP_TRACE_ERROR("can not generate confirm for unknown device\n");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BTM_ReadConnectionAddr( p_cb->pairing_bda, p_cb->local_bda, &p_cb->addr_type);
|
||||
@@ -670,6 +670,7 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
|
||||
SMP_TRACE_DEBUG("p1 = press || preq || rat' || iat'\n");
|
||||
smp_debug_print_nbyte_little_endian ((UINT8 *)p1, (const UINT8 *)"P1", 16);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -679,10 +680,10 @@ void smp_gen_p1_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p1)
|
||||
** Description Generate Confirm/Compare Step2:
|
||||
** p2 = padding || ia || ra
|
||||
**
|
||||
** Returns void
|
||||
** Returns FALSE if remote address unavailable, TRUE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
void smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2)
|
||||
BOOLEAN smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2)
|
||||
{
|
||||
UINT8 *p = (UINT8 *)p2;
|
||||
BD_ADDR remote_bda;
|
||||
@@ -690,7 +691,7 @@ void smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2)
|
||||
SMP_TRACE_DEBUG ("smp_gen_p2_4_confirm\n");
|
||||
if (!BTM_ReadRemoteConnectionAddr(p_cb->pairing_bda, remote_bda, &addr_type)) {
|
||||
SMP_TRACE_ERROR("can not generate confirm p2 for unknown device\n");
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
SMP_TRACE_DEBUG ("smp_gen_p2_4_confirm\n");
|
||||
@@ -712,6 +713,7 @@ void smp_gen_p2_4_confirm( tSMP_CB *p_cb, BT_OCTET16 p2)
|
||||
SMP_TRACE_DEBUG("p2 = padding || ia || ra");
|
||||
smp_debug_print_nbyte_little_endian(p2, (const UINT8 *)"p2", 16);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -733,7 +735,11 @@ void smp_calculate_comfirm (tSMP_CB *p_cb, BT_OCTET16 rand, BD_ADDR bda)
|
||||
|
||||
SMP_TRACE_DEBUG ("smp_calculate_comfirm \n");
|
||||
/* generate p1 = press || preq || rat' || iat' */
|
||||
smp_gen_p1_4_confirm(p_cb, p1);
|
||||
if (!smp_gen_p1_4_confirm(p_cb, p1)) {
|
||||
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
|
||||
return ;
|
||||
}
|
||||
|
||||
/* p1 = rand XOR p1 */
|
||||
smp_xor_128(p1, rand);
|
||||
@@ -771,7 +777,10 @@ static void smp_calculate_comfirm_cont(tSMP_CB *p_cb, tSMP_ENC *p)
|
||||
smp_debug_print_nbyte_little_endian (p->param_buf, (const UINT8 *)"C1", 16);
|
||||
#endif
|
||||
|
||||
smp_gen_p2_4_confirm(p_cb, p2);
|
||||
if (!smp_gen_p2_4_confirm(p_cb, p2)) {
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &status);
|
||||
return;
|
||||
}
|
||||
|
||||
/* calculate p2 = (p1' XOR p2) */
|
||||
smp_xor_128(p2, p->param_buf);
|
||||
@@ -1146,6 +1155,12 @@ void smp_continue_private_key_creation (tSMP_CB *p_cb, tBTM_RAND_ENC *p)
|
||||
UINT8 state = p_cb->rand_enc_proc_state & ~0x80;
|
||||
SMP_TRACE_DEBUG ("%s state=0x%x\n", __func__, state);
|
||||
|
||||
/* Validate param_len to prevent buffer overflow/underflow */
|
||||
if (p == NULL || p->param_len != BT_OCTET8_LEN) {
|
||||
SMP_TRACE_ERROR("invalid param_len: %d, expected %d\n", p ? p->param_len : 0, BT_OCTET8_LEN);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case SMP_GENERATE_PRIVATE_KEY_0_7:
|
||||
memcpy((void *)p_cb->private_key, p->param_buf, p->param_len);
|
||||
@@ -1258,6 +1273,7 @@ void smp_process_private_key(tSMP_CB *p_cb)
|
||||
p_cb->loc_publ_key.x[i] = pub_be[1 + BT_OCTET32_LEN - 1 - i];
|
||||
p_cb->loc_publ_key.y[i] = pub_be[33 + BT_OCTET32_LEN - 1 - i];
|
||||
}
|
||||
psa_ok = TRUE;
|
||||
|
||||
mbedtls_pubkey_cleanup:
|
||||
/* Clear sensitive data - mbedtls_ecp_keypair_free will zero the private key */
|
||||
@@ -1323,10 +1339,10 @@ mbedtls_pubkey_cleanup:
|
||||
** key and peer public key;
|
||||
** - saves the new public key x-coordinate as DHKey.
|
||||
**
|
||||
** Returns void
|
||||
** Returns TRUE if DHKey was computed successfully, FALSE otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void smp_compute_dhkey (tSMP_CB *p_cb)
|
||||
BOOLEAN smp_compute_dhkey (tSMP_CB *p_cb)
|
||||
{
|
||||
SMP_TRACE_DEBUG ("%s\n", __FUNCTION__);
|
||||
|
||||
@@ -1398,6 +1414,7 @@ void smp_compute_dhkey (tSMP_CB *p_cb)
|
||||
for (int i = 0; i < BT_OCTET32_LEN; i++) {
|
||||
p_cb->dhkey[i] = shared_secret[BT_OCTET32_LEN - 1 - i];
|
||||
}
|
||||
psa_ok = TRUE;
|
||||
|
||||
mbedtls_dhkey_cleanup:
|
||||
/* Clear sensitive data - mbedtls_mpi_free will zero the memory */
|
||||
@@ -1428,11 +1445,11 @@ mbedtls_dhkey_cleanup:
|
||||
|
||||
/* Validate peer public key */
|
||||
/* uECC_valid_public_key returns 0 if valid, negative value if invalid */
|
||||
if (uECC_valid_public_key(peer_pub_be, uECC_secp256r1()) < 0) {
|
||||
if (uECC_valid_public_key(peer_pub_be, uECC_secp256r1()) != 0) {
|
||||
SMP_TRACE_ERROR("%s Invalid peer public key\n", __FUNCTION__);
|
||||
memset(priv_be, 0, sizeof(priv_be));
|
||||
memset(peer_pub_be, 0, sizeof(peer_pub_be));
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Compute ECDH shared secret */
|
||||
@@ -1442,7 +1459,7 @@ mbedtls_dhkey_cleanup:
|
||||
memset(priv_be, 0, sizeof(priv_be));
|
||||
memset(peer_pub_be, 0, sizeof(peer_pub_be));
|
||||
memset(shared_secret, 0, sizeof(shared_secret));
|
||||
return;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Convert shared secret from big-endian to little-endian for DHKey */
|
||||
@@ -1463,9 +1480,16 @@ mbedtls_dhkey_cleanup:
|
||||
memcpy(peer_publ_key.x, p_cb->peer_publ_key.x, BT_OCTET32_LEN);
|
||||
memcpy(peer_publ_key.y, p_cb->peer_publ_key.y, BT_OCTET32_LEN);
|
||||
|
||||
if (!ECC_CheckPointIsInElliCur_P256(&peer_publ_key)) {
|
||||
SMP_TRACE_ERROR("%s Invalid peer public key\n", __FUNCTION__);
|
||||
memset(private_key, 0, sizeof(private_key));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ECC_PointMult(&new_publ_key, &peer_publ_key, (DWORD *) private_key, KEY_LENGTH_DWORDS_P256);
|
||||
|
||||
memcpy(p_cb->dhkey, new_publ_key.x, BT_OCTET32_LEN);
|
||||
memset(private_key, 0, sizeof(private_key));
|
||||
#endif /* SMP_CRYPTO_MBEDTLS */
|
||||
|
||||
smp_debug_print_nbyte_little_endian (p_cb->dhkey, (const UINT8 *)"DHKey",
|
||||
@@ -1477,6 +1501,7 @@ mbedtls_dhkey_cleanup:
|
||||
BT_OCTET32_LEN);
|
||||
smp_debug_print_nbyte_little_endian (p_cb->peer_publ_key.y, (const UINT8 *)"rem public(y)",
|
||||
BT_OCTET32_LEN);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1587,6 +1612,9 @@ void smp_calculate_peer_commitment(tSMP_CB *p_cb, BT_OCTET16 output_buf)
|
||||
**
|
||||
** Note The LSB is the first octet, the MSB is the last octet of
|
||||
** the AES-CMAC input/output stream.
|
||||
** In little-endian implementation, the message is constructed
|
||||
** as Z||V||U (reversed parameter order) to compensate for
|
||||
** byte order differences with the big-endian specification.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void smp_calculate_f4(UINT8 *u, UINT8 *v, UINT8 *x, UINT8 z, UINT8 *c)
|
||||
@@ -2085,11 +2113,16 @@ BOOLEAN smp_calculate_f5_key(UINT8 *w, UINT8 *t)
|
||||
*******************************************************************************/
|
||||
void smp_calculate_local_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
{
|
||||
UINT8 iocap[3], a[7], b[7];
|
||||
UINT8 iocap[3], a[7] = {0}, b[7] = {0};
|
||||
|
||||
SMP_TRACE_DEBUG ("%s", __FUNCTION__);
|
||||
|
||||
smp_calculate_f5_mackey_and_long_term_key(p_cb);
|
||||
if (!smp_calculate_f5_mackey_and_long_term_key(p_cb)) {
|
||||
UINT8 reason = SMP_PAIR_FAIL_UNKNOWN;
|
||||
p_cb->failure = reason;
|
||||
smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &reason);
|
||||
return;
|
||||
}
|
||||
|
||||
smp_collect_local_io_capabilities(iocap, p_cb);
|
||||
|
||||
@@ -2112,7 +2145,7 @@ void smp_calculate_local_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
*******************************************************************************/
|
||||
void smp_calculate_peer_dhkey_check(tSMP_CB *p_cb, tSMP_INT_DATA *p_data)
|
||||
{
|
||||
UINT8 iocap[3], a[7], b[7];
|
||||
UINT8 iocap[3], a[7] = {0}, b[7] = {0};
|
||||
BT_OCTET16 param_buf;
|
||||
BOOLEAN ret;
|
||||
tSMP_KEY key;
|
||||
@@ -2526,37 +2559,62 @@ static void smp_rand_back(tBTM_RAND_ENC *p)
|
||||
UINT8 *pp = NULL;
|
||||
UINT8 failure = SMP_PAIR_FAIL_UNKNOWN;
|
||||
UINT8 state = p_cb->rand_enc_proc_state & ~0x80;
|
||||
BOOLEAN check_failed = FALSE;
|
||||
|
||||
SMP_TRACE_DEBUG ("%s state=0x%x", __FUNCTION__, state);
|
||||
if (p && p->status == HCI_SUCCESS) {
|
||||
switch (state) {
|
||||
case SMP_GEN_SRAND_MRAND:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
memcpy((void *)p_cb->rand, p->param_buf, p->param_len);
|
||||
smp_generate_rand_cont(p_cb, NULL);
|
||||
break;
|
||||
|
||||
case SMP_GEN_SRAND_MRAND_CONT:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
memcpy((void *)&p_cb->rand[8], p->param_buf, p->param_len);
|
||||
smp_generate_confirm(p_cb, NULL);
|
||||
break;
|
||||
|
||||
case SMP_GEN_DIV_LTK:
|
||||
if (p->param_len < 2) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
pp = p->param_buf;
|
||||
STREAM_TO_UINT16(p_cb->div, pp);
|
||||
smp_generate_ltk_cont(p_cb, NULL);
|
||||
break;
|
||||
|
||||
case SMP_GEN_DIV_CSRK:
|
||||
if (p->param_len < 2) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
pp = p->param_buf;
|
||||
STREAM_TO_UINT16(p_cb->div, pp);
|
||||
smp_compute_csrk(p_cb, NULL);
|
||||
break;
|
||||
|
||||
case SMP_GEN_TK:
|
||||
if (p->param_len < 4) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
smp_proc_passkey(p_cb, p);
|
||||
break;
|
||||
|
||||
case SMP_GEN_RAND_V:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
memcpy(p_cb->enc_rand, p->param_buf, BT_OCTET8_LEN);
|
||||
smp_generate_y(p_cb, NULL);
|
||||
break;
|
||||
@@ -2565,21 +2623,34 @@ static void smp_rand_back(tBTM_RAND_ENC *p)
|
||||
case SMP_GENERATE_PRIVATE_KEY_8_15:
|
||||
case SMP_GENERATE_PRIVATE_KEY_16_23:
|
||||
case SMP_GENERATE_PRIVATE_KEY_24_31:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
smp_continue_private_key_creation(p_cb, p);
|
||||
break;
|
||||
|
||||
case SMP_GEN_NONCE_0_7:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
memcpy((void *)p_cb->rand, p->param_buf, p->param_len);
|
||||
smp_finish_nonce_generation(p_cb);
|
||||
break;
|
||||
|
||||
case SMP_GEN_NONCE_8_15:
|
||||
if (p->param_len != BT_OCTET8_LEN) {
|
||||
check_failed = TRUE;
|
||||
break;
|
||||
}
|
||||
memcpy((void *)&p_cb->rand[8], p->param_buf, p->param_len);
|
||||
smp_process_new_nonce(p_cb);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
if (!check_failed) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SMP_TRACE_ERROR("%s key generation failed: (%d)", __FUNCTION__, p_cb->rand_enc_proc_state);
|
||||
|
||||
@@ -118,8 +118,8 @@ static void smp_connect_callback (UINT16 channel, BD_ADDR bd_addr, BOOLEAN conne
|
||||
if (memcmp(bd_addr, p_cb->pairing_bda, BD_ADDR_LEN) == 0) {
|
||||
SMP_TRACE_EVENT ("%s() for pairing BDA: %08x%04x Event: %s\n",
|
||||
__FUNCTION__,
|
||||
(bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
|
||||
(bd_addr[4] << 8) + bd_addr[5],
|
||||
((UINT32)bd_addr[0] << 24) + ((UINT32)bd_addr[1] << 16) + ((UINT32)bd_addr[2] << 8) + bd_addr[3],
|
||||
((UINT32)bd_addr[4] << 8) + bd_addr[5],
|
||||
(connected) ? "connected" : "disconnected");
|
||||
|
||||
if (connected) {
|
||||
@@ -283,8 +283,8 @@ static void smp_br_connect_callback(UINT16 channel, BD_ADDR bd_addr, BOOLEAN con
|
||||
|
||||
SMP_TRACE_EVENT ("%s for pairing BDA: %08x%04x Event: %s\n",
|
||||
__func__,
|
||||
(bd_addr[0] << 24) + (bd_addr[1] << 16) + (bd_addr[2] << 8) + bd_addr[3],
|
||||
(bd_addr[4] << 8) + bd_addr[5],
|
||||
((UINT32)bd_addr[0] << 24) + ((UINT32)bd_addr[1] << 16) + ((UINT32)bd_addr[2] << 8) + bd_addr[3],
|
||||
((UINT32)bd_addr[4] << 8) + bd_addr[5],
|
||||
(connected) ? "connected" : "disconnected");
|
||||
|
||||
if (connected) {
|
||||
|
||||
@@ -746,7 +746,7 @@ void smp_sm_event(tSMP_CB *p_cb, tSMP_EVENT event, void *p_data)
|
||||
/* lookup entry /w event & curr_state */
|
||||
/* If entry is ignore, return.
|
||||
* Otherwise, get state table (according to curr_state or all_state) */
|
||||
if ((event <= SMP_MAX_EVT) && ( (entry = entry_table[event - 1][curr_state]) != SMP_SM_IGNORE )) {
|
||||
if ((event >= 1 && event <= SMP_MAX_EVT) && ( (entry = entry_table[event - 1][curr_state]) != SMP_SM_IGNORE )) {
|
||||
if (entry & SMP_ALL_TBL_MASK) {
|
||||
entry &= ~SMP_ALL_TBL_MASK;
|
||||
state_table = smp_all_table;
|
||||
@@ -803,7 +803,7 @@ const char *smp_get_event_name(tSMP_EVENT event)
|
||||
{
|
||||
const char *p_str = smp_event_name[SMP_MAX_EVT];
|
||||
|
||||
if (event <= SMP_MAX_EVT) {
|
||||
if (event >= 1 && event <= SMP_MAX_EVT) {
|
||||
p_str = smp_event_name[event - 1];
|
||||
}
|
||||
return p_str;
|
||||
|
||||
@@ -351,7 +351,7 @@ BOOLEAN smp_send_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
BOOLEAN sent = FALSE;
|
||||
UINT8 failure = SMP_PAIR_INTERNAL_ERR;
|
||||
SMP_TRACE_EVENT("smp_send_cmd on l2cap cmd_code=0x%x\n", cmd_code);
|
||||
if ( cmd_code <= (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */) &&
|
||||
if ( cmd_code < SMP_OPCODE_ARRAY_SIZE &&
|
||||
smp_cmd_build_act[cmd_code] != NULL) {
|
||||
p_buf = (*smp_cmd_build_act[cmd_code])(cmd_code, p_cb);
|
||||
|
||||
@@ -749,11 +749,14 @@ static BT_HDR *smp_build_pairing_commitment_cmd(UINT8 cmd_code, tSMP_CB *p_cb)
|
||||
UINT8 *p;
|
||||
UNUSED(cmd_code);
|
||||
|
||||
SMP_TRACE_EVENT("%s\n", __func__);
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(sizeof(BT_HDR) + SMP_PAIR_COMMITM_SIZE + L2CAP_MIN_OFFSET))
|
||||
!= NULL) {
|
||||
p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET;
|
||||
|
||||
/* The transmitter sends 0x03 universally.
|
||||
The receiver performs automatic conversion according to its capabilities to ensure backward compatibility.
|
||||
The state machine operates using the translated opcode. please refer to smp_data_received() in smp_l2c.c
|
||||
Please note that using SMP OPCODE to CONFIRM is not an error.
|
||||
*/
|
||||
UINT8_TO_STREAM (p, SMP_OPCODE_CONFIRM);
|
||||
ARRAY_TO_STREAM (p, p_cb->commitment, BT_OCTET16_LEN);
|
||||
|
||||
@@ -858,6 +861,11 @@ void smp_convert_string_to_tk(BT_OCTET16 tk, UINT32 passkey)
|
||||
void smp_mask_enc_key(UINT8 loc_enc_size, UINT8 *p_data)
|
||||
{
|
||||
SMP_TRACE_EVENT("smp_mask_enc_key\n");
|
||||
if (loc_enc_size < SMP_ENCR_KEY_SIZE_MIN) {
|
||||
SMP_TRACE_ERROR("smp_mask_enc_key: loc_enc_size %d below minimum %d\n",
|
||||
loc_enc_size, SMP_ENCR_KEY_SIZE_MIN);
|
||||
return;
|
||||
}
|
||||
if (loc_enc_size < BT_OCTET16_LEN) {
|
||||
for (; loc_enc_size < BT_OCTET16_LEN; loc_enc_size ++) {
|
||||
* (p_data + loc_enc_size) = 0;
|
||||
@@ -1057,7 +1065,7 @@ BOOLEAN smp_command_has_invalid_parameters(tSMP_CB *p_cb)
|
||||
|
||||
SMP_TRACE_DEBUG("%s for cmd code 0x%02x\n", __func__, cmd_code);
|
||||
|
||||
if ((cmd_code > (SMP_OPCODE_MAX + 1 /* for SMP_OPCODE_PAIR_COMMITM */)) ||
|
||||
if ((cmd_code >= SMP_OPCODE_ARRAY_SIZE) ||
|
||||
(cmd_code < SMP_OPCODE_MIN)) {
|
||||
SMP_TRACE_WARNING("Somehow received command with the RESERVED code 0x%02x\n", cmd_code);
|
||||
return TRUE;
|
||||
@@ -1462,7 +1470,7 @@ void smp_collect_peer_io_capabilities(UINT8 *iocap, tSMP_CB *p_cb)
|
||||
void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb)
|
||||
{
|
||||
tBLE_ADDR_TYPE addr_type = 0;
|
||||
BD_ADDR bda;
|
||||
BD_ADDR bda = {0};
|
||||
UINT8 *p = le_addr;
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
@@ -1485,7 +1493,7 @@ void smp_collect_local_ble_address(UINT8 *le_addr, tSMP_CB *p_cb)
|
||||
void smp_collect_peer_ble_address(UINT8 *le_addr, tSMP_CB *p_cb)
|
||||
{
|
||||
tBLE_ADDR_TYPE addr_type = 0;
|
||||
BD_ADDR bda;
|
||||
BD_ADDR bda = {0};
|
||||
UINT8 *p = le_addr;
|
||||
|
||||
SMP_TRACE_DEBUG("%s\n", __func__);
|
||||
@@ -1574,8 +1582,8 @@ void smp_save_secure_connections_long_term_key(tSMP_CB *p_cb)
|
||||
*******************************************************************************/
|
||||
BOOLEAN smp_calculate_f5_mackey_and_long_term_key(tSMP_CB *p_cb)
|
||||
{
|
||||
UINT8 a[7];
|
||||
UINT8 b[7];
|
||||
UINT8 a[7] = {0};
|
||||
UINT8 b[7] = {0};
|
||||
UINT8 *p_na;
|
||||
UINT8 *p_nb;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user