diff --git a/components/bt/bluedroid/api/esp_gap_ble_api.c b/components/bt/bluedroid/api/esp_gap_ble_api.c index 0dcd89cfee..9c444bb13e 100644 --- a/components/bt/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/bluedroid/api/esp_gap_ble_api.c @@ -179,6 +179,18 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +esp_err_t esp_ble_gap_clear_rand_addr(void) +{ + btc_msg_t msg; + + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS; + + return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable) { diff --git a/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h index d4bb690793..c4a5b95f9f 100644 --- a/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/bluedroid/api/include/api/esp_gap_ble_api.h @@ -820,10 +820,8 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params); */ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length); - - /** - * @brief This function set the random address for the application + * @brief This function sets the random address for the application * * @param[in] rand_addr: the random address which should be setting * @@ -834,6 +832,16 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_ */ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr); +/** + * @brief This function clears the random address for the application + * + * @return + * - ESP_OK : success + * - other : failed + * + */ +esp_err_t esp_ble_gap_clear_rand_addr(void); + /** diff --git a/components/bt/bluedroid/bta/dm/bta_dm_act.c b/components/bt/bluedroid/bta/dm/bta_dm_act.c index ab04118e8c..26d71f06c3 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_act.c @@ -765,6 +765,8 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data) if (continue_delete_dev) { bta_dm_process_remove_device(p_dev->bd_addr, transport); } + + BTM_ClearInqDb (p_dev->bd_addr); } /******************************************************************************* @@ -4687,6 +4689,12 @@ void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data) } +void bta_dm_ble_clear_rand_address(tBTA_DM_MSG *p_data) +{ + UNUSED(p_data); + BTM_BleClearRandAddress(); +} + /******************************************************************************* ** ** Function bta_dm_ble_stop_advertising diff --git a/components/bt/bluedroid/bta/dm/bta_dm_api.c b/components/bt/bluedroid/bta/dm/bta_dm_api.c index 83229e3ce0..a20a6efab9 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_api.c @@ -2392,6 +2392,16 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_ } } +void BTA_DmClearRandAddress(void) +{ + tBTA_DM_APT_CLEAR_ADDR *p_msg; + if ((p_msg = (tBTA_DM_APT_CLEAR_ADDR *) osi_malloc(sizeof(tBTA_DM_APT_CLEAR_ADDR))) != NULL) { + memset(p_msg, 0, sizeof(tBTA_DM_APT_CLEAR_ADDR)); + p_msg->hdr.event = BTA_DM_API_CLEAR_RAND_ADDR_EVT; + bta_sys_sendmsg(p_msg); + } +} + /******************************************************************************* ** ** Function BTA_VendorInit diff --git a/components/bt/bluedroid/bta/dm/bta_dm_main.c b/components/bt/bluedroid/bta/dm/bta_dm_main.c index 7f720799cc..aa651c267e 100644 --- a/components/bt/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/bluedroid/bta/dm/bta_dm_main.c @@ -107,7 +107,8 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { /* This handler function added by Yulong at 2016/9/9 to support the random address setting for the APP */ - bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT */ + bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/ + bta_dm_ble_clear_rand_address, /* BTA_DM_API_CLEAR_RAND_ADDR_EVT */ /* This handler function added by Yulong at 2016/10/19 to support stop the ble advertising setting diff --git a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h index 7a73c17b9f..c54f26728b 100644 --- a/components/bt/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/bluedroid/bta/dm/include/bta_dm_int.h @@ -106,6 +106,7 @@ enum { /*******This event added by Yulong at 2016/9/9 to support the random address setting for the APP******/ BTA_DM_API_SET_RAND_ADDR_EVT, + BTA_DM_API_CLEAR_RAND_ADDR_EVT, /*******This event added by Yulong at 2016/10/19 to support stop the ble advertising setting by the APP******/ BTA_DM_API_BLE_STOP_ADV_EVT, @@ -571,6 +572,10 @@ typedef struct { tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback; } tBTA_DM_APT_SET_DEV_ADDR; +typedef struct { + BT_HDR hdr; +} tBTA_DM_APT_CLEAR_ADDR; + /* set adv parameter for BLE advertising */ typedef struct { BT_HDR hdr; @@ -829,6 +834,7 @@ typedef union { tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params; tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length; tBTA_DM_APT_SET_DEV_ADDR set_addr; + tBTA_DM_APT_CLEAR_ADDR clear_addr; tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb; tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param; tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data; @@ -1224,6 +1230,7 @@ extern void bta_dm_ble_scan (tBTA_DM_MSG *p_data); extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data); extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_clear_rand_address(tBTA_DM_MSG *p_data); extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data); extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data); extern void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data); diff --git a/components/bt/bluedroid/bta/include/bta/bta_api.h b/components/bt/bluedroid/bta/include/bta/bta_api.h index 15c22ba61a..1546389bed 100644 --- a/components/bt/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/bluedroid/bta/include/bta/bta_api.h @@ -2121,6 +2121,7 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration, extern void BTA_DmBleStopAdvertising(void); extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback); +extern void BTA_DmClearRandAddress(void); #endif diff --git a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 33e1ea6701..e3c4262f8c 100644 --- a/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -839,6 +839,11 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK * } } +static void btc_ble_clear_rand_addr (void) +{ + BTA_DmClearRandAddress(); +} + static void btc_ble_config_local_privacy(bool privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback) { BTA_DmBleConfigLocalPrivacy(privacy_enable, set_local_privacy_cback); @@ -1043,6 +1048,10 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) btc_ble_set_rand_addr(bd_addr, btc_set_rand_addr_callback); break; } + case BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS: { + btc_ble_clear_rand_addr(); + break; + } case BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY: btc_ble_config_local_privacy(arg->cfg_local_privacy.privacy_enable, btc_set_local_privacy_callback); break; diff --git a/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h index c9e0f5645a..b737594816 100644 --- a/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -30,6 +30,7 @@ typedef enum { BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM, BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN, BTC_GAP_BLE_ACT_SET_RAND_ADDRESS, + BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS, BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY, BTC_GAP_BLE_ACT_CONFIG_LOCAL_ICON, BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST, diff --git a/components/bt/bluedroid/stack/btm/btm_ble_addr.c b/components/bt/bluedroid/stack/btm/btm_ble_addr.c index 785ed733fd..730d7895bc 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_addr.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_addr.c @@ -59,7 +59,8 @@ static void btm_gen_resolve_paddr_cmpl(tSMP_ENC *p) /* set it to controller */ btsnd_hcic_ble_set_random_addr(p_cb->private_addr); - p_cb->own_addr_type = BLE_ADDR_RANDOM; + 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; @@ -613,12 +614,7 @@ void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR dummy_bda = {0}; if (p != NULL) { -/* - * Temporary solutions for pair with random address: - * use BLE_ADDR_RANDOM when adverting with random adress or in privacy mode - * We will do futher work here - */ - if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE || btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) { + if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) { p->conn_addr_type = BLE_ADDR_RANDOM; if (memcmp(local_rpa, dummy_bda, BD_ADDR_LEN)) { memcpy(p->conn_addr, local_rpa, BD_ADDR_LEN); diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index 3caab465aa..a3d4b85126 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -760,20 +760,6 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK return FALSE; } -/* - * Temporary solutions for pair with random address: - * can't set privacy when advertising, scaning or using static random address - * We will do futher work here - */ - if (p_cb->privacy_mode == BTM_PRIVACY_NONE - && random_cb->own_addr_type == BLE_ADDR_RANDOM) { - BTM_TRACE_ERROR("Have set random adress, can't set privacy "); - if (random_cb && random_cb->set_local_privacy_cback){ - (*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL); - random_cb->set_local_privacy_cback = NULL; - } - return FALSE; - } if (!(p_cb->inq_var.state == BTM_BLE_STOP_SCAN || p_cb->inq_var.state == BTM_BLE_STOP_ADV || p_cb->inq_var.state == BTM_BLE_IDLE)) { BTM_TRACE_ERROR("Advertising or scaning now, can't set privacy "); if (random_cb && random_cb->set_local_privacy_cback){ @@ -787,6 +773,8 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK uint8_t addr_resolution = 0; #endif /* defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */ if (!privacy_mode) { /* if privacy disabled, always use public address */ + p_cb->addr_mgnt_cb.exist_addr_bit &= (~BTM_BLE_GAP_ADDR_BIT_RESOLVABLE); + memset(p_cb->addr_mgnt_cb.resolvale_addr, 0, BD_ADDR_LEN); p_cb->addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; p_cb->privacy_mode = BTM_PRIVACY_NONE; if (random_cb && random_cb->set_local_privacy_cback){ @@ -795,7 +783,6 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK } } else { /* privacy is turned on*/ /* always set host random address, used when privacy 1.1 or priavcy 1.2 is disabled */ - p_cb->addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; btm_gen_resolvable_private_addr((void *)btm_gen_resolve_paddr_low); if (BTM_BleMaxMultiAdvInstanceCount() > 0) { @@ -1232,17 +1219,66 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, return BTM_ILLEGAL_VALUE; } -/* - * Temporary solutions for pair with random address: - * can't set advertising with BLE_ADDR_PUBLIC when having set random adress or in privacy mode - * We will do futher work here - */ - if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && own_bda_type == BLE_ADDR_PUBLIC) { - BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n"); - if(adv_cb) { - (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); + if(own_bda_type == BLE_ADDR_RANDOM) { + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { + //close privacy + #if BLE_PRIVACY_SPT == TRUE + if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { + BTM_BleConfigPrivacy(FALSE, NULL); + } + #endif + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); + // set address to controller + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); + + } else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); + }else { + BTM_TRACE_ERROR ("No random address yet, please set random address and try\n"); + if(adv_cb) { + (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); + } + return BTM_ILLEGAL_VALUE; } - return BTM_ILLEGAL_VALUE; + } else if(own_bda_type == BLE_ADDR_PUBLIC_ID || own_bda_type == BLE_ADDR_RANDOM_ID) { + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { + own_bda_type = BLE_ADDR_RANDOM; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); + } else { + #if BLE_PRIVACY_SPT == TRUE + if(btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { + BTM_TRACE_ERROR ("Error state\n"); + if(adv_cb) { + (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); + } + return BTM_ILLEGAL_VALUE; + } + #endif + if(own_bda_type == BLE_ADDR_PUBLIC_ID) { + own_bda_type = BLE_ADDR_PUBLIC; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; + } else { //own_bda_type == BLE_ADDR_RANDOM_ID + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { + own_bda_type = BLE_ADDR_RANDOM; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); + } else { + BTM_TRACE_ERROR ("No RPA and no random address yet, please set RPA or random address and try\n"); + if(adv_cb) { + (* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL); + } + return BTM_ILLEGAL_VALUE; + } + } + } + } else { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; } if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || @@ -1414,17 +1450,67 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 return; } -/* - * Temporary solutions for pair with random address: - * can't set scan with BLE_ADDR_PUBLIC when having set random adress or in privacy mode - * We will do futher work here - */ - if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && addr_type_own == BLE_ADDR_PUBLIC) { - BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n"); - if (scan_setup_status_cback != NULL) { - scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); + if(addr_type_own == BLE_ADDR_RANDOM) { + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { + //close privacy + #if BLE_PRIVACY_SPT == TRUE + if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { + BTM_BleConfigPrivacy(FALSE, NULL); + } + #endif + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); + // set address to controller + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); + + } else if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); + }else { + if (scan_setup_status_cback != NULL) { + scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); + } + BTM_TRACE_ERROR ("No random address yet, please set random address and try\n"); + return; } - return; + } else if(addr_type_own == BLE_ADDR_PUBLIC_ID || addr_type_own == BLE_ADDR_RANDOM_ID) { + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) == BTM_BLE_GAP_ADDR_BIT_RESOLVABLE) { + addr_type_own = BLE_ADDR_RANDOM; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.resolvale_addr); + } else { + #if BLE_PRIVACY_SPT == TRUE + if(btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { + BTM_TRACE_ERROR ("Error state\n"); + if (scan_setup_status_cback != NULL) { + scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); + } + return; + } + #endif + if(addr_type_own == BLE_ADDR_PUBLIC_ID) { + addr_type_own = BLE_ADDR_PUBLIC; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; + } else { + //own_bda_type == BLE_ADDR_RANDOM_ID + if((btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit & BTM_BLE_GAP_ADDR_BIT_RANDOM) == BTM_BLE_GAP_ADDR_BIT_RANDOM) { + addr_type_own = BLE_ADDR_RANDOM; + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, BD_ADDR_LEN); + btsnd_hcic_ble_set_random_addr(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); + } else { + BTM_TRACE_ERROR ("No RPA and no random address yet, please set RPA or random address and try\n"); + if (scan_setup_status_cback != NULL) { + scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE); + } + return; + } + } + } + } else { + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; } /* If not supporting extended scan support, use the older range for checking */ @@ -1613,32 +1699,43 @@ tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr) if (rand_addr == NULL) return BTM_SET_STATIC_RAND_ADDR_FAIL; -/* - * Temporary solutions for pair with random address: - * can't set rand address when advertising, scaning or in privacy mode - * We will do futher work here - */ -#if BLE_PRIVACY_SPT == TRUE - if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) { - BTM_TRACE_ERROR("privacy_mode is not BTM_PRIVACY_NONE "); - return BTM_SET_STATIC_RAND_ADDR_FAIL; - } - -#endif if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) { BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state); return BTM_SET_STATIC_RAND_ADDR_FAIL; } memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, rand_addr, BD_ADDR_LEN); - btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM; + memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, rand_addr, BD_ADDR_LEN); //send the set random address to the controller if(btsnd_hcic_ble_set_random_addr(rand_addr)) { + btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit |= BTM_BLE_GAP_ADDR_BIT_RANDOM; return BTM_SUCCESS; } else { return BTM_SET_STATIC_RAND_ADDR_FAIL; } } +/******************************************************************************* +** +** Function BTM_BleClearRandAddress +** +** Description This function is called to clear the LE random address. +** +** Parameters: None. +** +** Returns void +** +*******************************************************************************/ +void BTM_BleClearRandAddress(void) +{ + tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; + if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && (!(p_cb->inq_var.state == BTM_BLE_STOP_SCAN || p_cb->inq_var.state == BTM_BLE_STOP_ADV || p_cb->inq_var.state == BTM_BLE_IDLE))) { + BTM_TRACE_ERROR("Advertising or scaning now, can't restore public address "); + return; + } + memset(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, 0, BD_ADDR_LEN); + btm_cb.ble_ctr_cb.addr_mgnt_cb.exist_addr_bit &= (~BTM_BLE_GAP_ADDR_BIT_RANDOM); + btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_PUBLIC; +} /******************************************************************************* ** ** Function BTM_BleGetCurrentAddress diff --git a/components/bt/bluedroid/stack/btm/btm_dev.c b/components/bt/bluedroid/stack/btm/btm_dev.c index d8073e112e..798f88e1b7 100644 --- a/components/bt/bluedroid/stack/btm/btm_dev.c +++ b/components/bt/bluedroid/stack/btm/btm_dev.c @@ -368,6 +368,10 @@ void btm_sec_free_dev (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport) btm_sec_clear_ble_keys (p_dev_rec); #endif } + /* No BLE keys and BT keys, clear the sec_flags */ + if(p_dev_rec->sec_flags == BTM_SEC_IN_USE) { + p_dev_rec->sec_flags = 0; + } } /******************************************************************************* diff --git a/components/bt/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/bluedroid/stack/btm/include/btm_ble_int.h index c080c9e7ea..b3b8ad10c2 100644 --- a/components/bt/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/bluedroid/stack/btm/include/btm_ble_int.h @@ -181,9 +181,15 @@ typedef void (tBTM_BLE_RESOLVE_CBACK) (void *match_rec, void *p); typedef void (tBTM_BLE_ADDR_CBACK) (BD_ADDR_PTR static_random, void *p); +#define BTM_BLE_GAP_ADDR_BIT_RANDOM (1<<0) +#define BTM_BLE_GAP_ADDR_BIT_RESOLVABLE (1<<1) + /* random address management control block */ typedef struct { tBLE_ADDR_TYPE own_addr_type; /* local device LE address type */ + UINT8 exist_addr_bit; + BD_ADDR static_rand_addr; + BD_ADDR resolvale_addr; BD_ADDR private_addr; BD_ADDR random_bda; BOOLEAN busy; diff --git a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h index 0a07c643b4..e0d67ee63b 100644 --- a/components/bt/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/bluedroid/stack/include/stack/btm_ble_api.h @@ -996,6 +996,8 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len); tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr); +void BTM_BleClearRandAddress(void); + /******************************************************************************* ** diff --git a/components/bt/bluedroid/stack/l2cap/l2c_ble.c b/components/bt/bluedroid/stack/l2cap/l2c_ble.c index 7329552106..552477a057 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_ble.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_ble.c @@ -805,7 +805,7 @@ BOOLEAN l2cble_init_direct_conn (tL2C_LCB *p_lcb) memcpy(peer_addr, p_lcb->remote_bd_addr, BD_ADDR_LEN); #if ( (defined BLE_PRIVACY_SPT) && (BLE_PRIVACY_SPT == TRUE)) - own_addr_type = btm_cb.ble_ctr_cb.privacy_mode ? BLE_ADDR_RANDOM : BLE_ADDR_PUBLIC; + own_addr_type = btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type; if(dev_rec_exist) { // if the current address information is valid, get the real address information if(p_dev_rec->ble.current_addr_valid) { diff --git a/components/bt/bluedroid/stack/l2cap/l2c_utils.c b/components/bt/bluedroid/stack/l2cap/l2c_utils.c index 978e020e65..ef92f5da41 100644 --- a/components/bt/bluedroid/stack/l2cap/l2c_utils.c +++ b/components/bt/bluedroid/stack/l2cap/l2c_utils.c @@ -2211,13 +2211,17 @@ BOOLEAN l2cu_create_conn (tL2C_LCB *p_lcb, tBT_TRANSPORT transport) #if (BLE_INCLUDED == TRUE) tBT_DEVICE_TYPE dev_type; tBLE_ADDR_TYPE addr_type = p_lcb->open_addr_type; - BTM_ReadDevInfo(p_lcb->remote_bd_addr, &dev_type, &addr_type); + if(addr_type == BLE_ADDR_UNKNOWN_TYPE) { + BTM_ReadDevInfo(p_lcb->remote_bd_addr, &dev_type, &addr_type); + } if (transport == BT_TRANSPORT_LE) { if (!controller_get_interface()->supports_ble()) { return FALSE; } - + if(addr_type > BLE_ADDR_TYPE_MAX) { + addr_type = BLE_ADDR_PUBLIC; + } p_lcb->ble_addr_type = addr_type; p_lcb->transport = BT_TRANSPORT_LE; diff --git a/components/bt/bluedroid/stack/smp/smp_utils.c b/components/bt/bluedroid/stack/smp/smp_utils.c index 31497591f0..cdb9c63fa7 100644 --- a/components/bt/bluedroid/stack/smp/smp_utils.c +++ b/components/bt/bluedroid/stack/smp/smp_utils.c @@ -590,8 +590,16 @@ static BT_HDR *smp_build_id_addr_cmd(UINT8 cmd_code, tSMP_CB *p_cb) p = (UINT8 *)(p_buf + 1) + L2CAP_MIN_OFFSET; UINT8_TO_STREAM (p, SMP_OPCODE_ID_ADDR); - UINT8_TO_STREAM (p, 0); - BDADDR_TO_STREAM (p, controller_get_interface()->get_address()->address); + /* Identity Address Information is used in the Transport Specific Key Distribution phase to distribute + its public device address or static random address. if slave using static random address is encrypted, + it should distribute its static random address */ + if(btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && memcmp(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr,6) == 0) { + UINT8_TO_STREAM (p, 0x01); + BDADDR_TO_STREAM (p, btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr); + } else { + UINT8_TO_STREAM (p, 0); + BDADDR_TO_STREAM (p, controller_get_interface()->get_address()->address); + } p_buf->offset = L2CAP_MIN_OFFSET; p_buf->len = SMP_ID_ADDR_SIZE; diff --git a/components/idf_test/integration_test/INIT_COND_SSC.yml b/components/idf_test/integration_test/INIT_COND_SSC.yml index e9359e2166..abdd492f2e 100644 --- a/components/idf_test/integration_test/INIT_COND_SSC.yml +++ b/components/idf_test/integration_test/INIT_COND_SSC.yml @@ -357,12 +357,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -385,12 +389,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -427,12 +435,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -455,12 +467,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -497,12 +513,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -527,12 +547,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -569,12 +593,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[2-5] bleadv -D -z start - - P SSC[2-5] C +BLEADV:Start,OK - - SSC SSC[2-5] gatts -S -z load -p 0xA2 @@ -599,12 +627,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[2-5] bleadv -D -z start - - P SSC[2-5] C +BLEADV:Start,OK - - SSC SSC[2-5] gatts -S -z load -p 0xA2 @@ -641,12 +673,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC1 gatts -S -z load -p 0xA2 - - R SSC1 C +GATTS:StartService,OK,A002 - - LOOP 4 2 "[2,3,4,5]" "[2,3,4,5]" @@ -669,12 +705,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC1 gatts -S -z load -p 0xA2 - - R SSC1 C +GATTS:StartService,OK,A002 - - SSC SSC[2-5] gattc -F -r @@ -711,12 +751,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[1-3] gatts -S -z load -p 0xA2 - - R SSC[1-3] C +GATTS:StartService,OK,A002 - - LOOP 2 2 "[4,5]" "[4,5]" @@ -744,12 +788,16 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[1-3] gatts -S -z load -p 0xA2 - - R SSC[1-3] C +GATTS:StartService,OK,A002 - - LOOP 2 2 "[4,5]" "[4,5]" @@ -792,13 +840,15 @@ initial condition: - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Succes + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -832,13 +882,15 @@ initial condition: - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Succes + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -955,6 +1007,8 @@ initial condition: - - 'R SSC1 C +BLE:' - - SSC SSC1 bleconn -D -z all - - 'R SSC1 C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success force restore cmd set: - '' - - SSC SSC1 reboot @@ -972,6 +1026,8 @@ initial condition: - [] - - SSC SSC1 bleconn -D -z all - - 'R SSC1 C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC1 gatts -S -z delete - - 'R SSC1 C +GATTS:' - - SSC SSC1 gattc -U -z all @@ -1009,6 +1065,8 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all @@ -1017,6 +1075,8 @@ initial condition: - - R SSC2 C +GATTS:StartService,OK,A000 - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -1052,6 +1112,8 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all @@ -1060,6 +1122,8 @@ initial condition: - - R SSC2 C +GATTS:StartService,OK,A002 - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 bleadv -L -c 0 -t 3 - - R SSC2 C +BLEADV:SetAdv,OK - - SSC SSC2 bleadv -D -z start @@ -1096,6 +1160,8 @@ initial condition: - - 'R SSC[1-5] C +BLE:' - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' + - - SSC SSC[1-5] blesmp -B -z clear + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all @@ -1104,6 +1170,8 @@ initial condition: - ["P SSC[2-5] C +GATTS:StartService,OK,A000"] - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC1 gattc -F -r - - R SSC1 C +GATTC:OK - - SSC SSC1 ram @@ -1130,13 +1198,15 @@ initial condition: - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Succes + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 gatts -S -z load -p 0xA2 - - R SSC2 C +GATTS:StartService,OK,A002 - - SSC SSC2 bleadv -L -c 0 -t 3 @@ -1159,13 +1229,15 @@ initial condition: - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' - - SSC SSC[1-2] blesmp -B -z clear - - - R SSC[1-2] C +BLESMP:ClearBond,Succes + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC2 gatts -S -z load -p 0xA2 - - R SSC2 C +GATTS:StartService,OK,A002 - - SSC SSC2 bleadv -L -c 0 -t 3 @@ -1200,13 +1272,15 @@ initial condition: - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Succes + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[2-5] gatts -S -z load -p 0xA0 - - R SSC[2-5] C +GATTS:StartService,OK,A000 - - SSC SSC[2-5] bleadv -L -c 0 -t 3 @@ -1226,13 +1300,15 @@ initial condition: - - SSC SSC[1-5] bleconn -D -z all - - 'R SSC[1-5] C +BLECONN:' - - SSC SSC[1-5] blesmp -B -z clear - - - R SSC[1-5] C +BLESMP:ClearBond,Succes + - - R SSC[1-5] C +BLESMP:ClearBond,Success - - SSC SSC[1-5] gatts -S -z delete - - 'R SSC[1-5] C +GATTS:' - - SSC SSC[1-5] gattc -U -z all - - R SSC[1-5] C +GATTC:OK - - SSC SSC[1-5] bleadv -D -z stop - - R SSC[1-5] C +BLEADV:OK + - - SSC SSC[1-5] ble -S -z public + - - R SSC[1-5] C +BLE:OK - - SSC SSC[2-5] gatts -S -z load -p 0xA0 - - R SSC[2-5] C +GATTS:StartService,OK,A000 - - SSC SSC[2-5] bleadv -L -c 0 -t 3 @@ -2100,12 +2176,16 @@ initial condition: - - 'R SSC[1-2] C +BLE:' - - SSC SSC[1-2] bleconn -D -z all - - 'R SSC[1-2] C +BLECONN:' + - - SSC SSC[1-2] blesmp -B -z clear + - - R SSC[1-2] C +BLESMP:ClearBond,Success - - SSC SSC[1-2] gatts -S -z delete - - 'R SSC[1-2] C +GATTS:' - - SSC SSC[1-2] gattc -U -z all - - R SSC[1-2] C +GATTC:OK - - SSC SSC[1-2] bleadv -D -z stop - - R SSC[1-2] C +BLEADV:OK + - - SSC SSC[1-2] ble -S -z public + - - R SSC[1-2] C +BLE:OK - - SSC SSC1 ram - - R SSC1 A :(\d+) - tag: T3_1 diff --git a/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml b/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml index 52f508c42e..4aa6754e08 100644 --- a/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml +++ b/components/idf_test/integration_test/TC_IT_BTSTK_GAP.yml @@ -808,9 +808,7 @@ test cases: - - "SSC SSC2 bleadv -D -z start -t 0 -o 2" - ["R SSC2 C +BLEADV:OK"] - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 P C Complete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLE:GattcConnect,OK", "R SSC2 C +BLE:GattsConnect"] + - ["R SSC1 NP C Complete"] - ID: BTSTK_GAP_03009 <<: *GAP_CASE test point 2: BLE GAP set advertise param @@ -860,7 +858,6 @@ test cases: - ["R SSC1 C +BLE:GattcConnect,OK", "R SSC2 C +BLE:GattsConnect"] - ID: BTSTK_GAP_03010 <<: *GAP_CASE - CI ready: "No" # can't restore to use public address after set to use private address test point 2: BLE GAP set advertise param summary: ble adv with privacy address and RPA_RANDOM initial condition: BLE_INIT_SMP @@ -881,12 +878,9 @@ test cases: - - "SSC SSC2 bleadv -D -z start -t 0 -o 3" - ["R SSC2 C +BLEADV:OK"] - - "SSC SSC1 blescan -D -z start" - - ["R SSC1 P C Complete"] - - - "SSC SSC1 bleconn -C -p 0x10 -a " - - ["R SSC1 C +BLE:GattcConnect,OK", "R SSC2 C +BLE:GattsConnect"] + - ["R SSC1 NP C Complete"] - ID: BTSTK_GAP_03011 <<: *GAP_CASE - CI ready: "No" # can't restore to use public address after set to use private address test point 2: BLE GAP set advertise param summary: ble set adv owner address type as RPA_RANDOM initial condition: BLE_INIT_SMP