diff options
Diffstat (limited to 'stack/btm/btm_ble.c')
-rw-r--r-- | stack/btm/btm_ble.c | 383 |
1 files changed, 306 insertions, 77 deletions
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c index 74b5767d1..1d2cdf30c 100644 --- a/stack/btm/btm_ble.c +++ b/stack/btm/btm_ble.c @@ -31,14 +31,15 @@ #include "btm_int.h" #include "btm_ble_api.h" #include "smp_api.h" +#include "l2c_int.h" +#include "gap_api.h" #if SMP_INCLUDED == TRUE extern BOOLEAN AES_CMAC ( BT_OCTET16 key, UINT8 *input, UINT16 length, UINT16 tlen, UINT8 *p_signature); extern void smp_link_encrypted(BD_ADDR bda, UINT8 encr_enable); extern BOOLEAN smp_proc_ltk_request(BD_ADDR bda); #endif - -static void btm_ble_update_active_bgconn_scan_params(void); +extern void gatt_notify_enc_cmpl(BD_ADDR bd_addr); /*******************************************************************************/ /* External Function to be called by other modules */ @@ -114,7 +115,7 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, tBT_DEVICE_TYPE d { p_dev_rec->sec_flags |= BTM_SEC_NAME_KNOWN; BCM_STRNCPY_S ((char *)p_dev_rec->sec_bd_name, sizeof (p_dev_rec->sec_bd_name), - (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); + (char *)bd_name, BTM_MAX_REM_BD_NAME_LEN); } p_dev_rec->device_type = dev_type; p_dev_rec->ble.ble_addr_type = addr_type; @@ -158,9 +159,10 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_ p_dev_rec = btm_find_dev (bd_addr); if (!p_dev_rec || !p_le_key || (key_type != BTM_LE_KEY_PENC && key_type != BTM_LE_KEY_PID && - key_type != BTM_LE_KEY_PCSRK && key_type != BTM_LE_KEY_LENC)) + key_type != BTM_LE_KEY_PCSRK && key_type != BTM_LE_KEY_LENC && + key_type != BTM_LE_KEY_LCSRK)) { - BTM_TRACE_WARNING3 ("BTM_SecAddLeKey() No BT Link Key, Wrong Type, or No Device record \ + BTM_TRACE_WARNING3 ("BTM_SecAddBleKey() Wrong Type, or No Device record \ for bdaddr: %08x%04x, Type: %d", (bd_addr[0]<<24)+(bd_addr[1]<<16)+(bd_addr[2]<<8)+bd_addr[3], (bd_addr[4]<<8)+bd_addr[5], key_type); @@ -283,29 +285,54 @@ void BTM_GetDeviceDHK (BT_OCTET16 dhk) ** ** Function BTM_ReadConnectionAddr ** -** Description This function is called to set the local device random address +** Description This function is called to get the local device address information ** . ** ** Returns void ** *******************************************************************************/ -void BTM_ReadConnectionAddr (BD_ADDR conn_addr) +void BTM_ReadConnectionAddr (BD_ADDR remote_bda, BD_ADDR local_conn_addr, tBLE_ADDR_TYPE *p_addr_type) { #if BLE_INCLUDED == TRUE - BTM_TRACE_DEBUG0 ("BTM_ReadConnectionAddr"); - if (btm_cb.ble_ctr_cb.inq_var.own_addr_type == BLE_ADDR_PUBLIC) - { - BTM_GetLocalDeviceAddr(conn_addr); - } - else + tACL_CONN *p_acl = btm_bda_to_acl(remote_bda); + + if (p_acl == NULL) { - memcpy (conn_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, BD_ADDR_LEN); + BTM_TRACE_ERROR0("No connection exist!"); + return; } + memcpy(local_conn_addr, p_acl->conn_addr, BD_ADDR_LEN); + * p_addr_type = p_acl->conn_addr_type; + + BTM_TRACE_DEBUG2 ("BTM_ReadConnectionAddr address type: %d addr: 0x%02x", + p_acl->conn_addr_type, p_acl->conn_addr[0]); + #endif } /******************************************************************************* ** +** Function BTM_ReadRemoteConnectionAddr +** +** Description This function is read the remote device address currently used +** . +** +** Returns void +** +*******************************************************************************/ +BOOLEAN BTM_ReadRemoteConnectionAddr(BD_ADDR pseudo_addr, BD_ADDR conn_addr, tBLE_ADDR_TYPE *p_addr_type) +{ + BOOLEAN st = TRUE; +#if BLE_INCLUDED == TRUE + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev(pseudo_addr); + + memcpy(conn_addr, pseudo_addr, BD_ADDR_LEN); + *p_addr_type = p_dev_rec->ble.ble_addr_type; +#endif + return st; +} +/******************************************************************************* +** ** Function BTM_SecurityGrant ** ** Description This function is called to grant security process. @@ -346,6 +373,12 @@ void BTM_BlePasskeyReply (BD_ADDR bd_addr, UINT8 res, UINT32 passkey) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); tSMP_STATUS res_smp = (res == BTM_SUCCESS) ? SMP_SUCCESS : SMP_PASSKEY_ENTRY_FAIL; + if (p_dev_rec == NULL) + { + BTM_TRACE_ERROR0("Passkey reply to Unknown device"); + return; + } + p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_AUTHED; BTM_TRACE_DEBUG0 ("BTM_BlePasskeyReply"); SMP_PasskeyReply(bd_addr, res_smp, passkey); @@ -371,6 +404,13 @@ void BTM_BleOobDataReply(BD_ADDR bd_addr, UINT8 res, UINT8 len, UINT8 *p_data) tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); BTM_TRACE_DEBUG0 ("BTM_BleOobDataReply"); + + if (p_dev_rec == NULL) + { + BTM_TRACE_ERROR0("BTM_BleOobDataReply() to Unknown device"); + return; + } + p_dev_rec->sec_flags |= BTM_SEC_LINK_KEY_AUTHED; SMP_OobDataReply(bd_addr, res_smp, len, p_data); #endif @@ -411,8 +451,10 @@ void BTM_BleSetConnScanParams (UINT16 scan_interval, UINT16 scan_window) new_param = TRUE; } - if (new_param) - btm_ble_update_active_bgconn_scan_params(); + if (new_param && p_ble_cb->conn_state == BLE_BG_CONN) + { + btm_ble_suspend_bg_conn(); + } } else { @@ -452,7 +494,7 @@ void BTM_BleSetPrefConnParams (BD_ADDR bd_addr, if (BTM_BLE_VALID_PRAM(min_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && BTM_BLE_VALID_PRAM(max_conn_int, BTM_BLE_CONN_INT_MIN, BTM_BLE_CONN_INT_MAX) && BTM_BLE_VALID_PRAM(supervision_tout, BTM_BLE_CONN_SUP_TOUT_MIN, BTM_BLE_CONN_SUP_TOUT_MAX) && - slave_latency <= BTM_BLE_CONN_LATENCY_MAX) + (slave_latency <= BTM_BLE_CONN_LATENCY_MAX || slave_latency == BTM_BLE_CONN_PARAM_UNDEF)) { if (p_dev_rec) { @@ -544,41 +586,83 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR return; } +/******************************************************************************* +** +** Function BTM_BleReceiverTest +** +** Description This function is called to start the LE Receiver test +** +** Parameter rx_freq - Frequency Range +** p_cmd_cmpl_cback - Command Complete callback +** +*******************************************************************************/ +void BTM_BleReceiverTest(UINT8 rx_freq, tBTM_CMPL_CB *p_cmd_cmpl_cback) +{ + btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback; + + if (btsnd_hcic_ble_receiver_test(rx_freq) == FALSE) + { + BTM_TRACE_ERROR1("%s: Unable to Trigger LE receiver test", __FUNCTION__); + } +} /******************************************************************************* -** Internal Functions +** +** Function BTM_BleTransmitterTest +** +** Description This function is called to start the LE Transmitter test +** +** Parameter tx_freq - Frequency Range +** test_data_len - Length in bytes of payload data in each packet +** packet_payload - Pattern to use in the payload +** p_cmd_cmpl_cback - Command Complete callback +** *******************************************************************************/ -#if BLE_INCLUDED == TRUE +void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, + UINT8 packet_payload, tBTM_CMPL_CB *p_cmd_cmpl_cback) +{ + btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback; + if (btsnd_hcic_ble_transmitter_test(tx_freq, test_data_len, packet_payload) == FALSE) + { + BTM_TRACE_ERROR1("%s: Unable to Trigger LE transmitter test", __FUNCTION__); + } +} /******************************************************************************* ** -** Function btm_ble_update_active_bgconn_scan_params +** Function BTM_BleTestEnd +** +** Description This function is called to stop the in-progress TX or RX test ** -** Description This function is called to update the scan parameter if background -** connection has been active. +** Parameter p_cmd_cmpl_cback - Command complete callback ** *******************************************************************************/ -static void btm_ble_update_active_bgconn_scan_params(void) +void BTM_BleTestEnd(tBTM_CMPL_CB *p_cmd_cmpl_cback) { - tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; - tBTM_BLE_SEL_CBACK *p_select_cback; + btm_cb.devcb.p_le_test_cmd_cmpl_cb = p_cmd_cmpl_cback; + + if (btsnd_hcic_ble_test_end() == FALSE) + { + BTM_TRACE_ERROR1("%s: Unable to End the LE TX/RX test", __FUNCTION__); + } +} + +/******************************************************************************* +** Internal Functions +*******************************************************************************/ +#if BLE_INCLUDED == TRUE - /* if active , cancel and restart and apply the params */ - if (p_cb->bg_conn_state == BLE_BG_CONN_ACTIVE) +void btm_ble_test_command_complete(UINT8 *p) +{ + tBTM_CMPL_CB *p_cb = btm_cb.devcb.p_le_test_cmd_cmpl_cb; + UINT8 status; + + btm_cb.devcb.p_le_test_cmd_cmpl_cb = NULL; + + if (p_cb) { - if (p_cb->bg_conn_type == BTM_BLE_CONN_AUTO) - { - if (btm_ble_start_auto_conn(FALSE)) - btm_ble_start_auto_conn(TRUE); - } - else if (p_cb->bg_conn_type == BTM_BLE_CONN_SELECTIVE) - { - p_select_cback = p_cb->p_select_cback; - if (btm_ble_start_select_conn(FALSE, NULL)) - btm_ble_start_select_conn(TRUE, p_select_cback); - } + (*p_cb)(p); } - return; } /******************************************************************************* @@ -643,7 +727,7 @@ void btm_ble_rand_enc_complete (UINT8 *p, UINT16 op_code, tBTM_RAND_ENC_CB *p_en } -#if (SMP_INCLUDED == TRUE) + #if (SMP_INCLUDED == TRUE) /******************************************************************************* ** @@ -744,6 +828,7 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY { tBTM_SEC_DEV_REC *p_rec; tBTM_LE_EVT_DATA cb_data; + UINT8 i; BTM_TRACE_DEBUG2 ("btm_sec_save_le_key key_type=0x%x pass_to_application=%d",key_type, pass_to_application); /* Store the updated key in the device database */ @@ -776,7 +861,14 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY break; case BTM_LE_KEY_PID: - memcpy(p_rec->ble.keys.irk, p_keys->pid_key, BT_OCTET16_LEN); + for (i=0; i<BT_OCTET16_LEN; i++) + { + p_rec->ble.keys.irk[i] = p_keys->pid_key.irk[i]; + } + + //memcpy( p_rec->ble.keys.irk, p_keys->pid_key, BT_OCTET16_LEN); todo will crash the system + memcpy(p_rec->ble.static_addr, p_keys->pid_key.static_addr, BD_ADDR_LEN); + p_rec->ble.static_addr_type = p_keys->pid_key.addr_type; p_rec->ble.key_type |= BTM_LE_KEY_PID; BTM_TRACE_DEBUG1("BTM_LE_KEY_PID key_type=0x%x save peer IRK", p_rec->ble.key_type); break; @@ -839,7 +931,6 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY { cb_data.key.p_key_value = p_keys; cb_data.key.key_type = key_type; - (*btm_cb.api.p_le_callback) (BTM_LE_KEY_EVT, bd_addr, &cb_data); } return; @@ -919,7 +1010,8 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE return; } - if (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) + if (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING || + p_dev_rec->sec_state == BTM_SEC_STATE_AUTHENTICATING) { /* race condition: discard the security request while master is encrypting the link */ *p_sec_req_act = BTM_BLE_SEC_REQ_ACT_DISCARD; @@ -960,12 +1052,13 @@ void btm_ble_link_sec_check(BD_ADDR bd_addr, tBTM_LE_AUTH_REQ auth_req, tBTM_BLE } else { - /* To avoid re-encryption on an encrypted link for an equal condition encryption + /* To avoid re-encryption on an encrypted link for an equal condition encryption */ + /* if link has been encrypted, do nothing, go straight to furhter action if (p_dev_rec->sec_flags & BTM_SEC_ENCRYPTED) *p_sec_req_act = BTM_BLE_SEC_REQ_ACT_DISCARD; else */ - *p_sec_req_act = BTM_BLE_SEC_REQ_ACT_ENCRYPT; + *p_sec_req_act = BTM_BLE_SEC_REQ_ACT_ENCRYPT; } } else @@ -1000,13 +1093,14 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin tBTM_BLE_SEC_ACT sec_act = *(tBTM_BLE_SEC_ACT *)p_ref_data ; tBTM_SEC_DEV_REC *p_rec = btm_find_dev (bd_addr); - BTM_TRACE_DEBUG2 ("btm_ble_set_encryption sec_act=0x%x role_master=%d", sec_act, p_rec->role_master); - if (p_rec == NULL) { + BTM_TRACE_WARNING1 ("btm_ble_set_encryption (NULL device record!! sec_act=0x%x", sec_act); return(BTM_WRONG_MODE); } + BTM_TRACE_DEBUG2 ("btm_ble_set_encryption sec_act=0x%x role_master=%d", sec_act, p_rec->role_master); + if (sec_act == BTM_BLE_SEC_ENCRYPT_MITM) { p_rec->security_required |= BTM_SEC_IN_MITM; @@ -1018,9 +1112,11 @@ tBTM_STATUS btm_ble_set_encryption (BD_ADDR bd_addr, void *p_ref_data, UINT8 lin if (link_role == BTM_ROLE_MASTER) { /* start link layer encryption using the security info stored */ - btm_ble_start_encrypt(bd_addr, FALSE, NULL); - p_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; - cmd = BTM_CMD_STARTED; + if (btm_ble_start_encrypt(bd_addr, FALSE, NULL)) + { + p_rec->sec_state = BTM_SEC_STATE_ENCRYPTING; + cmd = BTM_CMD_STARTED; + } break; } /* if salve role then fall through to call SMP_Pair below which will send a @@ -1123,30 +1219,36 @@ BOOLEAN btm_ble_start_encrypt(BD_ADDR bda, BOOLEAN use_stk, BT_OCTET16 stk) void btm_ble_link_encrypted(BD_ADDR bd_addr, UINT8 encr_enable) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); + BOOLEAN enc_cback; + + if (!p_dev_rec) + { + BTM_TRACE_WARNING1 ("btm_ble_link_encrypted (No Device Found!) encr_enable=%d", encr_enable); + return; + } BTM_TRACE_DEBUG1 ("btm_ble_link_encrypted encr_enable=%d", encr_enable); + enc_cback = (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING); + smp_link_encrypted(bd_addr, encr_enable); - if (p_dev_rec) - { - BTM_TRACE_DEBUG1(" p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags); + BTM_TRACE_DEBUG1(" p_dev_rec->sec_flags=0x%x", p_dev_rec->sec_flags); - if (encr_enable && p_dev_rec->enc_key_size == 0) - p_dev_rec->enc_key_size = p_dev_rec->ble.keys.key_size; + if (encr_enable && p_dev_rec->enc_key_size == 0) + p_dev_rec->enc_key_size = p_dev_rec->ble.keys.key_size; + + p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; + if (p_dev_rec->p_callback && enc_cback) + { + if (encr_enable) + btm_sec_dev_rec_cback_event(p_dev_rec, BTM_SUCCESS); + else if (p_dev_rec->role_master) + btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING); - if (p_dev_rec->p_callback) - { - if (p_dev_rec->sec_state == BTM_SEC_STATE_ENCRYPTING) - { - if (encr_enable) - btm_sec_dev_rec_cback_event(p_dev_rec, BTM_SUCCESS); - else if (p_dev_rec->role_master) - btm_sec_dev_rec_cback_event(p_dev_rec, BTM_ERR_PROCESSING); - } - } - p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; } + /* to notify GATT to send data if any request is pending */ + gatt_notify_enc_cmpl(p_dev_rec->bd_addr); } /******************************************************************************* @@ -1186,7 +1288,7 @@ static void btm_enc_proc_slave_y(tSMP_ENC *p) p_dev_rec = btm_find_dev_by_handle (p_cb->enc_handle); if ( p_dev_rec && - p_dev_rec->ble.keys.div == div ) + p_dev_rec->ble.keys.div == div ) { BTM_TRACE_DEBUG0 ("LTK request OK"); /* calculating LTK , LTK = E er(div) */ @@ -1305,6 +1407,110 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p return callback_rc; } +/******************************************************************************* +** +** Function btm_ble_connected +** +** Description This function is when a LE connection to the peer device is +** establsihed +** +** Returns void +** +*******************************************************************************/ +void btm_ble_connected (UINT8 *bda, UINT16 handle, UINT8 enc_mode, UINT8 role, + tBLE_ADDR_TYPE addr_type, BOOLEAN addr_matched) +{ + tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda); + tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; + + BTM_TRACE_EVENT0 ("btm_ble_connected"); + + /* Commenting out trace due to obf/compilation problems. + */ +#if (BT_USE_TRACES == TRUE) + if (p_dev_rec) + { + BTM_TRACE_EVENT4 ("Security Manager: btm_sec_connected : handle:%d enc_mode:%d bda:%x RName:%s", + handle, enc_mode, + (bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5], + p_dev_rec->sec_bd_name); + + BTM_TRACE_DEBUG1 ("btm_ble_connected sec_flags=0x%x",p_dev_rec->sec_flags); + } + else + { + BTM_TRACE_EVENT3 ("Security Manager: btm_sec_connected: handle:%d enc_mode:%d bda:%x ", + handle, enc_mode, + (bda[2]<<24)+(bda[3]<<16)+(bda[4]<<8)+bda[5]); + } +#endif + + if (!p_dev_rec) + { + /* There is no device record for new connection. Allocate one */ + p_dev_rec = btm_sec_alloc_dev (bda); + } + else /* Update the timestamp for this device */ + { + p_dev_rec->timestamp = btm_cb.dev_rec_count++; + } + + /* update device information */ + p_dev_rec->device_type |= BT_DEVICE_TYPE_BLE; + p_dev_rec->hci_handle = handle; + p_dev_rec->ble.ble_addr_type = addr_type; + + if (role == HCI_ROLE_MASTER) + p_dev_rec->role_master = TRUE; + + if (role == HCI_ROLE_SLAVE) + p_cb->inq_var.adv_mode = BTM_BLE_ADV_DISABLE; + p_cb->inq_var.directed_conn = FALSE; + + return; +} + +/***************************************************************************** +** Function btm_ble_conn_complete +** +** Description LE connection complete. +** +******************************************************************************/ +void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len) +{ + UINT8 role, status, bda_type; + UINT16 handle; + BD_ADDR bda; + UINT16 conn_interval, conn_latency, conn_timeout; + BOOLEAN match = FALSE; + + STREAM_TO_UINT8 (status, p); + STREAM_TO_UINT16 (handle, p); + STREAM_TO_UINT8 (role, p); + STREAM_TO_UINT8 (bda_type, p); + STREAM_TO_BDADDR (bda, p); + + if (status == 0) + { + STREAM_TO_UINT16 (conn_interval, p); + STREAM_TO_UINT16 (conn_latency, p); + STREAM_TO_UINT16 (conn_timeout, p); + handle = HCID_GET_HANDLE (handle); + + btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type, match); + l2cble_conn_comp (handle, role, bda, bda_type, conn_interval, + conn_latency, conn_timeout); + } + else + { + role = HCI_ROLE_UNKNOWN; + + if (status == HCI_ERR_DIRECTED_ADVERTISING_TIMEOUT) + btm_ble_dir_adv_tout(); + } + btm_ble_update_mode_operation(role, bda, TRUE); +} + /***************************************************************************** ** Function btm_proc_smp_cback ** @@ -1314,7 +1520,7 @@ UINT8 btm_ble_io_capabilities_req(tBTM_SEC_DEV_REC *p_dev_rec, tBTM_LE_IO_REQ *p UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) { tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bd_addr); - UINT8 res; + UINT8 res = 0; BTM_TRACE_DEBUG1 ("btm_proc_smp_cback event = %d", event); @@ -1336,11 +1542,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) { /* the callback function implementation may change the IO capability... */ BTM_TRACE_DEBUG1 ("btm_cb.api.p_le_callback=0x%x", btm_cb.api.p_le_callback ); - (*btm_cb.api.p_le_callback) (event, bd_addr, (tBTM_LE_EVT_DATA *)p_data); - } - else - { - BTM_TRACE_ERROR0 ("btm_proc_smp_cback: btm_cb.api.p_le_callback ==NULL"); + (*btm_cb.api.p_le_callback) (event, bd_addr, (tBTM_LE_EVT_DATA *)p_data); } if (event == SMP_COMPLT_EVT) @@ -1370,7 +1572,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) else { BTM_TRACE_DEBUG0 ("Pairing failed - Not Removing ACL"); - p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; + p_dev_rec->sec_state = BTM_SEC_STATE_IDLE; } } #else @@ -1406,7 +1608,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data) return 0; } -#endif /* SMP_INCLUDED */ + #endif /* SMP_INCLUDED */ #endif /* BLE_INCLUDED */ @@ -1548,7 +1750,7 @@ BOOLEAN BTM_BleDataSignature (BD_ADDR bd_addr, UINT8 *p_text, UINT16 len, ** *******************************************************************************/ BOOLEAN BTM_BleVerifySignature (BD_ADDR bd_addr, UINT8 *p_orig, UINT16 len, UINT32 counter, - UINT8 *p_comp) + UINT8 *p_comp) { BOOLEAN verified = FALSE; #if (BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE) @@ -1844,7 +2046,7 @@ void btm_ble_reset_id( void ) } } -#if BTM_BLE_CONFORMANCE_TESTING == TRUE + #if BTM_BLE_CONFORMANCE_TESTING == TRUE /******************************************************************************* ** ** Function btm_ble_set_no_disc_if_pair_fail @@ -1894,6 +2096,33 @@ void btm_ble_set_test_local_sign_cntr_value(BOOLEAN enable, UINT32 test_local_si btm_cb.devcb.test_local_sign_cntr = test_local_sign_cntr; } +/******************************************************************************* +** +** Function btm_set_random_address +** +** Description This function set a random address to local controller. +** +** Returns void +** +*******************************************************************************/ +void btm_set_random_address(BD_ADDR random_bda) +{ + tBTM_LE_RANDOM_CB *p_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; + BOOLEAN adv_mode = btm_cb.ble_ctr_cb.inq_var.adv_mode ; + + BTM_TRACE_DEBUG0 ("btm_set_random_address"); + + if (adv_mode == BTM_BLE_ADV_ENABLE) + btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE); + + memcpy(p_cb->private_addr, random_bda, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(p_cb->private_addr); + + if (adv_mode == BTM_BLE_ADV_ENABLE) + btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE); + + +} #endif /* BTM_BLE_CONFORMANCE_TESTING */ |