diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index 078724141d..5d67d62239 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -204,6 +204,25 @@ 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, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout) +{ + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + if (rpa_timeout < 0x0001 || rpa_timeout > 0x0E10) { + return ESP_ERR_INVALID_ARG; + } + + btc_msg_t msg = {0}; + btc_ble_gap_args_t arg; + + msg.sig = BTC_SIG_API_CALL; + msg.pid = BTC_PID_GAP_BLE; + msg.act = BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT; + arg.set_rpa_timeout.rpa_timeout = rpa_timeout; + + return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); +} + esp_err_t esp_ble_gap_clear_rand_addr(void) { btc_msg_t msg; diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index e96b4e0ee2..b8660c921d 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -157,7 +157,7 @@ typedef enum { ESP_GAP_BLE_PASSKEY_REQ_EVT, /*!< passkey request event */ ESP_GAP_BLE_OOB_REQ_EVT, /*!< OOB request event */ ESP_GAP_BLE_LOCAL_IR_EVT, /*!< BLE local IR (identity Root 128-bit random static value used to generate Long Term Key) event */ - ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root vakue used to genrate identity resolving key) event */ + ESP_GAP_BLE_LOCAL_ER_EVT, /*!< BLE local ER (Encryption Root value used to generate identity resolving key) event */ ESP_GAP_BLE_NC_REQ_EVT, /*!< Numeric Comparison request event */ //BLE_42_FEATURE_SUPPORT ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT, /*!< When stop adv complete, the event comes */ @@ -225,7 +225,8 @@ typedef enum { ESP_GAP_BLE_DTM_TEST_UPDATE_EVT, /*!< when direct test mode state changes, the event comes */ // BLE_INCLUDED ESP_GAP_BLE_ADV_CLEAR_COMPLETE_EVT, /*!< When clear advertising complete, the event comes */ - ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */ + ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */ + ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT, /*!< When set the Resolvable Private Address (RPA) timeout completes, the event comes */ ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */ } esp_gap_ble_cb_event_t; @@ -799,9 +800,9 @@ typedef uint8_t esp_ble_gap_all_phys_t; #define ESP_BLE_GAP_PRI_PHY_CODED ESP_BLE_GAP_PHY_CODED /*!< Primary Phy is LE CODED */ typedef uint8_t esp_ble_gap_pri_phy_t; // primary phy -#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or reciever PHY */ -#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or reciever PHY */ -#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or reciever PHY */ +#define ESP_BLE_GAP_PHY_1M_PREF_MASK (1 << 0) /*!< The Host prefers use the LE1M transmitter or receiver PHY */ +#define ESP_BLE_GAP_PHY_2M_PREF_MASK (1 << 1) /*!< The Host prefers use the LE2M transmitter or receiver PHY */ +#define ESP_BLE_GAP_PHY_CODED_PREF_MASK (1 << 2) /*!< The Host prefers use the LE CODED transmitter or receiver PHY */ typedef uint8_t esp_ble_gap_phy_mask_t; #define ESP_BLE_GAP_PHY_OPTIONS_NO_PREF 0 /*!< The Host has no preferred coding when transmitting on the LE Coded PHY */ @@ -1153,6 +1154,12 @@ typedef union { struct ble_local_privacy_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate the set local privacy operation success status */ } local_privacy_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT */ + /** + * @brief ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT + */ + struct ble_rpa_timeout_cmpl_evt_param { + esp_bt_status_t status; /*!< Indicate the set RPA timeout operation success status */ + } set_rpa_timeout_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT */ /** * @brief ESP_GAP_BLE_REMOVE_BOND_DEV_COMPLETE_EVT */ @@ -1644,6 +1651,23 @@ 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 sets the length of time the Controller uses a Resolvable Private Address + * before generating and starting to use a new resolvable private address. + * + * @note Note: This function is currently not supported on the ESP32 but will be enabled in a future update. + * + * @param[in] rpa_timeout: The timeout duration in seconds for how long a Resolvable Private Address + * is used before a new one is generated. The value must be within the range specified by + * the Bluetooth specification (0x0001 to 0x0E10), which corresponds to a time range of + * 1 second to 1 hour. The default value is 0x0384 (900 seconds or 15 minutes). + * @return + * - ESP_OK : success + * - other : failed + * + */ +esp_err_t esp_ble_gap_set_resolvable_private_address_timeout(uint16_t rpa_timeout); + /** * @brief This function clears the random address for the application * diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index c11f923010..3539574469 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -651,7 +651,7 @@ static void bta_dm_disable_timer_cback (TIMER_LIST_ENT *p_tle) } /* Retrigger disable timer in case ACL disconnect failed, DISABLE_EVT still need - to be sent out to avoid jave layer disable timeout */ + to be sent out to avoid the layer disable timeout */ if (trigger_disc) { bta_dm_cb.disable_timer.p_cback = (TIMER_CBACK *)&bta_dm_disable_timer_cback; bta_dm_cb.disable_timer.param = 1; @@ -763,7 +763,7 @@ static BOOLEAN bta_dm_read_remote_device_name (BD_ADDR bd_addr, tBT_TRANSPORT tr APPL_TRACE_DEBUG("bta_dm_read_remote_device_name: BTM_ReadRemoteDeviceName is busy"); /* Remote name discovery is on going now so BTM cannot notify through "bta_dm_remname_cback" */ - /* adding callback to get notified that current reading remore name done */ + /* adding callback to get notified that current reading remote name done */ BTM_SecAddRmtNameNotifyCallback(&bta_dm_service_search_remname_cback); return (TRUE); @@ -1117,7 +1117,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data) } if (p_dev->is_trusted) { - /* covert BTA service mask to BTM mask */ + /* convert BTA service mask to BTM mask */ while (p_dev->tm && (index < BTA_MAX_SERVICE_ID)) { if (p_dev->tm & (UINT32)(1 << index)) { @@ -1145,7 +1145,7 @@ void bta_dm_add_device (tBTA_DM_MSG *p_data) ** Function bta_dm_close_acl ** ** Description This function forces to close the connection to a remote device -** and optionaly remove the device from security database if +** and optionally remove the device from security database if ** required. **** *******************************************************************************/ @@ -2670,7 +2670,7 @@ static void bta_dm_discover_device(BD_ADDR remote_bd_addr) &bta_dm_search_cb.services_found ); } - /* if seaching with EIR is not completed */ + /* if searching with EIR is not completed */ if (bta_dm_search_cb.services_to_search) { /* check whether connection already exists to the device if connection exists, we don't have to wait for ACL @@ -3744,7 +3744,7 @@ static void bta_dm_disable_conn_down_timer_cback (TIMER_LIST_ENT *p_tle) tBTA_SYS_HW_MSG *sys_enable_event; #if (BTA_DM_PM_INCLUDED == TRUE) - /* disable the power managment module */ + /* disable the power management module */ bta_dm_disable_pm(); #endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */ @@ -4131,7 +4131,7 @@ static void bta_dm_set_eir (char *local_name) p = (UINT8 *)p_buf + BTM_HCI_EIR_OFFSET; /* reset p */ #endif // BTA_EIR_CANNED_UUID_LIST - /* if UUID doesn't fit remaing space, shorten local name */ + /* if UUID doesn't fit remaining space, shorten local name */ if ( local_name_len > (free_eir_length - 4 - num_uuid * LEN_UUID_16)) { APPL_TRACE_WARNING("BTA EIR: local name is shortened"); local_name_len = p_bta_dm_eir_cfg->bta_dm_eir_min_name_len; @@ -5179,14 +5179,14 @@ void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data) ** ** Description This function set the LE random address for the device. ** -** Parameters: rand_addr:the random address whitch should be setting +** Parameters: rand_addr:the random address which should be setting ** Explanation: This function added by Yulong at 2016/9/9 *******************************************************************************/ void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data) { tBTM_STATUS status = BTM_SET_STATIC_RAND_ADDR_FAIL; if (p_data->set_addr.addr_type != BLE_ADDR_RANDOM) { - APPL_TRACE_ERROR("Invalid random adress type = %d\n", p_data->set_addr.addr_type); + APPL_TRACE_ERROR("Invalid random address type = %d\n", p_data->set_addr.addr_type); if(p_data->set_addr.p_set_rand_addr_cback) { (*p_data->set_addr.p_set_rand_addr_cback)(status); } @@ -5541,7 +5541,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data) } p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback; - // if the value of the data length is same, triger callback directly + // if the value of the data length is same, trigger callback directly if(p_data->ble_set_data_length.tx_data_length == p_acl_cb->data_length_params.tx_len) { if(p_data->ble_set_data_length.p_set_pkt_data_cback) { (*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params); @@ -5550,7 +5550,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data) } if(p_acl_cb->data_len_updating) { - // aleady have one cmd + // already have one cmd if(p_acl_cb->data_len_waiting) { status = BTM_ILLEGAL_ACTION; } else { @@ -5736,6 +5736,12 @@ void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data) } } +void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data) +{ + APPL_TRACE_API("%s, rpa_timeout = %d", __func__, p_data->set_rpa_timeout.rpa_timeout); + BTM_BleSetRpaTimeout(p_data->set_rpa_timeout.rpa_timeout,p_data->set_rpa_timeout.p_set_rpa_timeout_cback); +} + #if (BLE_50_FEATURE_SUPPORT == TRUE) void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data) { @@ -6417,7 +6423,7 @@ static void bta_dm_gatt_disc_result(tBTA_GATT_ID service_id) } } else { - APPL_TRACE_ERROR("%s out of room to accomodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used ); + APPL_TRACE_ERROR("%s out of room to accommodate more service ids ble_raw_size = %d ble_raw_used = %d", __FUNCTION__, bta_dm_search_cb.ble_raw_size, bta_dm_search_cb.ble_raw_used ); } APPL_TRACE_API("%s service_id_uuid_len=%d ", __func__, service_id.uuid.len); diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index 816b213496..a318c449ca 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -887,7 +887,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key, ** ** Function BTA_DmRemoveDevice ** -** Description This function removes a device fromthe security database list of +** Description This function removes a device from the security database list of ** peer device. It manages unpairing even while connected. ** ** @@ -1105,7 +1105,7 @@ void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, int auth_mode ** Description Send BLE SMP passkey reply. ** ** Parameters: bd_addr - BD address of the peer -** accept - passkey entry sucessful or declined. +** accept - passkey entry successful or declined. ** passkey - passkey value, must be a 6 digit number, ** can be lead by 0. ** @@ -1944,7 +1944,7 @@ void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, ** p_services: if service is not empty, service discovery will be done. ** for all GATT based service condition, put num_uuid, and ** p_uuid is the pointer to the list of UUID values. -** p_cback: callback functino when search is completed. +** p_cback: callback function when search is completed. ** ** ** @@ -2032,7 +2032,7 @@ void BTA_DmBleUpdateConnectionParam(BD_ADDR bd_addr, UINT16 min_int, ** ** Description Enable/disable privacy on the local device ** -** Parameters: privacy_enable - enable/disabe privacy on remote device. +** Parameters: privacy_enable - enable/disable privacy on remote device. ** ** Returns void ** @@ -2084,7 +2084,7 @@ void BTA_DmBleConfigLocalIcon(uint16_t icon) ** ** Function BTA_BleEnableAdvInstance ** -** Description This function enable a Multi-ADV instance with the specififed +** Description This function enable a Multi-ADV instance with the specified ** adv parameters ** ** Parameters p_params: pointer to the adv parameter structure. @@ -2123,7 +2123,7 @@ void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params, ** ** Function BTA_BleUpdateAdvInstParam ** -** Description This function update a Multi-ADV instance with the specififed +** Description This function update a Multi-ADV instance with the specified ** adv parameters. ** ** Parameters inst_id: Adv instance to update the parameter. @@ -2154,7 +2154,7 @@ void BTA_BleUpdateAdvInstParam (UINT8 inst_id, tBTA_BLE_ADV_PARAMS *p_params) ** ** Function BTA_BleCfgAdvInstData ** -** Description This function configure a Multi-ADV instance with the specififed +** Description This function configure a Multi-ADV instance with the specified ** adv data or scan response data. ** ** Parameter inst_id: Adv instance to configure the adv data or scan response. @@ -2597,7 +2597,7 @@ void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) ** ** Parameters: bd_addr - Address of the peer device ** transport - transport of the link to be encruypted -** p_callback - Pointer to callback function to indicat the +** p_callback - Pointer to callback function to indicate the ** link encryption status ** sec_act - This is the security action to indicate ** what kind of BLE security level is required for @@ -2777,7 +2777,7 @@ extern void BTA_DmBleStopAdvertising(void) ** ** Description This function set the random address for the APP ** -** Parameters rand_addr: the random address whith should be setting +** Parameters rand_addr: the random address with should be setting ** p_set_rand_addr_cback: complete callback ** Returns void ** @@ -2793,7 +2793,34 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_ p_msg->hdr.event = BTA_DM_API_SET_RAND_ADDR_EVT; p_msg->addr_type = BLE_ADDR_RANDOM; p_msg->p_set_rand_addr_cback = p_set_rand_addr_cback; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module + bta_sys_sendmsg(p_msg); + } +} +/******************************************************************************* +** +** Function BTA_DmBleSetRpaTimeout +** +** Description This function sets the Resolvable Private Address (RPA) timeout +** for the Bluetooth device. The RPA timeout defines how long an RPA +** remains in use before a new one is generated. +** +** Parameters rpa_timeout: The timeout in seconds within the range of 1s to 1 hour +** as defined by the Bluetooth specification. This duration +** specifies how long the controller uses an RPA before +** generating a new one. +** Returns void +** +** +*******************************************************************************/ +void BTA_DmBleSetRpaTimeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback) +{ + tBTA_DM_API_SET_RPA_TIMEOUT *p_msg; + if ((p_msg = (tBTA_DM_API_SET_RPA_TIMEOUT *) osi_malloc(sizeof(tBTA_DM_API_SET_RPA_TIMEOUT))) != NULL) { + memset(p_msg, 0, sizeof(tBTA_DM_API_SET_RPA_TIMEOUT)); + p_msg->hdr.event = BTA_DM_API_SET_RPA_TIMEOUT_EVT; + p_msg->rpa_timeout = rpa_timeout; // Assign the RPA timeout value to the message + p_msg->p_set_rpa_timeout_cback = p_set_rpa_timeout_cback; bta_sys_sendmsg(p_msg); } } @@ -2863,7 +2890,7 @@ void BTA_DmBleGapReadPHY(BD_ADDR addr) memset(p_msg, 0, sizeof(tBTA_DM_API_READ_PHY)); p_msg->hdr.event = BTA_DM_API_READ_PHY_EVT; memcpy(p_msg->bd_addr, addr, BD_ADDR_LEN); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2875,13 +2902,13 @@ void BTA_DmBleGapSetPreferedDefaultPHY(tBTA_DM_BLE_GAP_PHY_MASK tx_phy_mask, tBTA_DM_BLE_GAP_PHY_MASK rx_phy_mask) { tBTA_DM_API_SET_PER_DEF_PHY *p_msg; - APPL_TRACE_API("%s, Set prefered default phy.", __func__); + APPL_TRACE_API("%s, Set preferred default phy.", __func__); if ((p_msg = (tBTA_DM_API_SET_PER_DEF_PHY *) osi_malloc(sizeof(tBTA_DM_API_SET_PER_DEF_PHY))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PER_DEF_PHY)); p_msg->hdr.event = BTA_DM_API_SET_PER_DEF_PHY_EVT; p_msg->tx_phy_mask = tx_phy_mask; p_msg->rx_phy_mask = rx_phy_mask; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2896,7 +2923,7 @@ void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr, UINT16 phy_options) { tBTA_DM_API_SET_PER_PHY *p_msg; - APPL_TRACE_API("%s, Set prefered phy.", __func__); + APPL_TRACE_API("%s, Set preferred phy.", __func__); if ((p_msg = (tBTA_DM_API_SET_PER_PHY *) osi_malloc(sizeof(tBTA_DM_API_SET_PER_PHY))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_SET_PER_PHY)); p_msg->hdr.event = BTA_DM_API_SET_PER_PHY_EVT; @@ -2905,7 +2932,7 @@ void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr, p_msg->tx_phy_mask = tx_phy_mask; p_msg->rx_phy_mask = rx_phy_mask; p_msg->phy_options = phy_options; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2921,7 +2948,7 @@ void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr) p_msg->hdr.event = BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT; p_msg->instance = instance; memcpy(&p_msg->rand_addr, addr, BD_ADDR_LEN); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2939,7 +2966,7 @@ void BTA_DmBleGapExtAdvSetParams(UINT16 instance, p_msg->hdr.event = BTA_DM_API_SET_EXT_ADV_PARAMS_EVT; p_msg->instance = instance; memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_GAP_EXT_ADV_PARAMS)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2962,7 +2989,7 @@ void BTA_DmBleGapConfigExtAdvDataRaw(BOOLEAN is_scan_rsp, UINT8 instance, UINT16 if (data) { memcpy(p_msg->data, data, length); } - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2982,7 +3009,7 @@ void BTA_DmBleGapExtAdvEnable(BOOLEAN enable, UINT8 num, tBTA_DM_BLE_EXT_ADV *ex if (ext_adv) { memcpy(p_msg->ext_adv, ext_adv, sizeof(tBTA_DM_BLE_EXT_ADV)*num); } - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -2997,7 +3024,7 @@ void BTA_DmBleGapExtAdvSetRemove(UINT8 instance) memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE)); p_msg->hdr.event = BTA_DM_API_EXT_ADV_SET_REMOVE_EVT; p_msg->instance = instance; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3011,7 +3038,7 @@ void BTA_DmBleGapExtAdvSetClear(void) if ((p_msg = (tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR *) osi_malloc(sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR)); p_msg->hdr.event = BTA_DM_API_EXT_ADV_SET_CLEAR_EVT; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3028,7 +3055,7 @@ void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance, p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT; p_msg->instance = instance; memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_Periodic_Adv_Params)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3050,7 +3077,7 @@ void BTA_DmBleGapPeriodicAdvCfgDataRaw(UINT8 instance, UINT16 length, memcpy(p_msg->data, data, length); p_msg->data = length != 0 ? (UINT8 *)(p_msg + 1) : NULL; p_msg->only_update_did = only_update_did; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3067,7 +3094,7 @@ void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance) p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_ENABLE_EVT; p_msg->instance = instance; p_msg->enable = enable; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3083,7 +3110,7 @@ void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params) memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC)); p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_EVT; memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_Periodic_Sync_Params)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3098,7 +3125,7 @@ void BTA_DmBleGapPeriodicAdvSyncCancel(void) if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL)); p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3114,7 +3141,7 @@ void BTA_DmBleGapPeriodicAdvSyncTerm(UINT16 sync_handle) memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_SYNC_TERM)); p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT; p_msg->sync_handle = sync_handle; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3134,7 +3161,7 @@ void BTA_DmBleGapPeriodicAdvAddDevToList(tBLE_ADDR_TYPE addr_type, p_msg->addr_type = addr_type; p_msg->sid = sid; memcpy(p_msg->addr, addr, sizeof(BD_ADDR)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3154,7 +3181,7 @@ void BTA_DmBleGapPeriodicAdvRemoveDevFromList(tBLE_ADDR_TYPE addr_type, p_msg->addr_type = addr_type; p_msg->sid = sid; memcpy(p_msg->addr, addr, sizeof(BD_ADDR)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3169,7 +3196,7 @@ void BTA_DmBleGapPeriodicAdvClearDev(void) if ((p_msg = (tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR *) osi_malloc(sizeof(tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR))) != NULL) { memset(p_msg, 0, sizeof(tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR)); p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3185,7 +3212,7 @@ void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params) memset(p_msg, 0, sizeof(tBTA_DM_API_SET_EXT_SCAN_PARAMS)); p_msg->hdr.event = BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT; memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_EXT_SCAN_PARAMS)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3203,7 +3230,7 @@ void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period) p_msg->start = start; p_msg->duration = duration; p_msg->period = period; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3237,7 +3264,7 @@ void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr, if (phy_coded_conn_params) { memcpy(&p_msg->phy_coded_conn_params, phy_coded_conn_params, sizeof(tBTA_DM_BLE_CONN_PARAMS)); } - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3256,7 +3283,7 @@ void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_add p_msg->hdr.event = BTA_DM_API_EXT_CONN_EVT; p_msg->own_addr_type = own_addr_type; memcpy(p_msg->peer_addr, peer_addr, sizeof(BD_ADDR)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3309,7 +3336,7 @@ void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable) p_msg->hdr.event = BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT; p_msg->sync_handle = sync_handle; p_msg->enable = enable; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3326,7 +3353,7 @@ void BTA_DmBleGapPeriodicAdvSyncTrans(BD_ADDR peer_addr, UINT16 service_data, UI memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR)); p_msg->service_data = service_data; p_msg->sync_handle = sync_handle; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3343,7 +3370,7 @@ void BTA_DmBleGapPeriodicAdvSetInfoTrans(BD_ADDR peer_addr, UINT16 service_data, memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR)); p_msg->service_data = service_data; p_msg->adv_hanlde = adv_handle; - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); @@ -3359,7 +3386,7 @@ void BTA_DmBleGapSetPeriodicAdvSyncTransParams(BD_ADDR peer_addr, tBTA_DM_BLE_PA p_msg->hdr.event = BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT; memcpy(p_msg->addr, peer_addr, sizeof(BD_ADDR)); memcpy(&p_msg->params, params, sizeof(tBTA_DM_BLE_PAST_PARAMS)); - //start sent the msg to the bta system control moudle + //start sent the msg to the bta system control module bta_sys_sendmsg(p_msg); } else { APPL_TRACE_ERROR("%s malloc failed", __func__); diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 7f5b52a69a..f5082a0558 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -219,6 +219,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_gap_dtm_rx_start, /* BTA_DM_API_DTM_RX_START_EVT */ bta_dm_ble_gap_dtm_stop, /* BTA_DM_API_DTM_STOP_EVT */ bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */ + bta_dm_ble_gap_set_rpa_timeout, /* BTA_DM_API_SET_RPA_TIMEOUT_EVT */ #endif }; diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 7d61b7080c..02578df0c6 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -76,7 +76,7 @@ enum { BTA_DM_API_PIN_REPLY_EVT, #endif ///SMP_INCLUDED == TRUE #if (BTA_DM_PM_INCLUDED == TRUE) - /* power manger events */ + /* power manager events */ BTA_DM_PM_BTM_STATUS_EVT, BTA_DM_PM_TIMER_EVT, #endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */ @@ -215,6 +215,7 @@ enum { BTA_DM_API_DTM_RX_START_EVT, BTA_DM_API_DTM_STOP_EVT, BTA_DM_API_BLE_CLEAR_ADV_EVT, + BTA_DM_API_SET_RPA_TIMEOUT_EVT, #endif BTA_DM_MAX_EVT }; @@ -642,7 +643,7 @@ typedef struct { tBTA_DM_BLE_SEL_CBACK *p_select_cback; } tBTA_DM_API_BLE_SET_BG_CONN_TYPE; -/* set prefered BLE connection parameters for a device */ +/* set preferred BLE connection parameters for a device */ typedef struct { BT_HDR hdr; BD_ADDR peer_bda; @@ -743,6 +744,12 @@ typedef struct { BT_HDR hdr; } tBTA_DM_APT_CLEAR_ADDR; +typedef struct { + BT_HDR hdr; + UINT16 rpa_timeout; + tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback; +} tBTA_DM_API_SET_RPA_TIMEOUT; + /* set adv parameter for BLE advertising */ typedef struct { BT_HDR hdr; @@ -1239,6 +1246,7 @@ typedef union { 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_SET_RPA_TIMEOUT set_rpa_timeout; 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; @@ -1422,7 +1430,7 @@ typedef struct { UINT32 role_policy_mask; /* the bits set indicates the modules that wants to remove role switch from the default link policy */ UINT16 cur_policy; /* current default link policy */ UINT16 rs_event; /* the event waiting for role switch */ - UINT8 cur_av_count; /* current AV connecions */ + UINT8 cur_av_count; /* current AV connections */ BOOLEAN disable_pair_mode; /* disable pair mode or not */ BOOLEAN conn_paired_only; /* allow connectable to paired device only or not */ tBTA_DM_API_SEARCH search_msg; @@ -1725,7 +1733,7 @@ extern void bta_dm_ble_gap_dtm_tx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_rx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_stop(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data); - +extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data); #if (BLE_50_FEATURE_SUPPORT == TRUE) extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index ad362ba045..e29695e16e 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -398,7 +398,7 @@ typedef tBTM_BLE_128SERVICE tBTA_BLE_128SERVICE; typedef tBTM_BLE_32SERVICE tBTA_BLE_32SERVICE; typedef struct { - tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */ + tBTA_BLE_INT_RANGE int_range; /* slave preferred conn interval range */ tBTA_BLE_MANU *p_manu; /* manufacturer data */ tBTA_BLE_SERVICE *p_services; /* 16 bits services */ tBTA_BLE_128SERVICE *p_services_128b; /* 128 bits service */ @@ -433,6 +433,8 @@ typedef tBTM_SET_RAND_ADDR_CBACK tBTA_SET_RAND_ADDR_CBACK; typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK; +typedef tBTM_SET_RPA_TIMEOUT_CMPL_CBACK tBTA_SET_RPA_TIMEOUT_CMPL_CBACK; + typedef tBTM_CMPL_CB tBTA_CMPL_CB; typedef tBTM_VSC_CMPL tBTA_VSC_CMPL; @@ -662,7 +664,7 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK; // btla-specific -- #define BTA_DM_DEV_UNPAIRED_EVT 25 /* BT unpair event */ #define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */ -#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */ +#define BTA_DM_LE_FEATURES_READ 27 /* Controller specific LE features are read */ #define BTA_DM_ENER_INFO_READ 28 /* Energy info read */ #define BTA_DM_BLE_DEV_UNPAIRED_EVT 29 /* BLE unpair event */ #define BTA_DM_SP_KEY_REQ_EVT 30 /* Simple Pairing Passkey request */ @@ -1101,7 +1103,7 @@ typedef struct { #define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */ #define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */ #define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */ -#define BTA_DM_DISC_BLE_RES_EVT 3 /* Discovery result for BLE GATT based servoce on a peer device. */ +#define BTA_DM_DISC_BLE_RES_EVT 3 /* Discovery result for BLE GATT based service on a peer device. */ #define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */ #define BTA_DM_DI_DISC_CMPL_EVT 5 /* Discovery complete. */ #define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */ @@ -1888,7 +1890,7 @@ extern void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, ** ** Function BTA_DmGetCachedRemoteName ** -** Description Retieve cached remote name if available +** Description Retrieve cached remote name if available ** ** Returns BTA_SUCCESS if cached name was retrieved ** BTA_FAILURE if cached name is not available @@ -2239,7 +2241,7 @@ extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_B ** Description Send BLE SMP passkey reply. ** ** Parameters: bd_addr - BD address of the peer -** accept - passkey entry sucessful or declined. +** accept - passkey entry successful or declined. ** passkey - passkey value, must be a 6 digit number, ** can be lead by 0. ** @@ -2405,7 +2407,7 @@ extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interva ** ** Parameters: adv_int_min - adv interval minimum ** adv_int_max - adv interval max -** p_dir_bda - directed adv initator address +** p_dir_bda - directed adv initiator address ** ** Returns void ** @@ -2431,7 +2433,7 @@ extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, ** services: if service is not empty, service discovery will be done. ** for all GATT based service condition, put num_uuid, and ** p_uuid is the pointer to the list of UUID values. -** p_cback: callback functino when search is completed. +** p_cback: callback function when search is completed. ** ** ** @@ -2490,7 +2492,7 @@ extern void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_ ** ** Parameters: bd_addr - Address of the peer device ** transport - transport of the link to be encruypted -** p_callback - Pointer to callback function to indicat the +** p_callback - Pointer to callback function to indicate the ** link encryption status ** sec_act - This is the security action to indicate ** what knid of BLE security level is required for @@ -2547,7 +2549,7 @@ 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); - +extern void BTA_DmBleSetRpaTimeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback); #endif #if BLE_INCLUDED == TRUE @@ -2558,7 +2560,7 @@ extern void BTA_DmClearRandAddress(void); ** ** Description Enable/disable privacy on the local device ** -** Parameters: privacy_enable - enable/disabe privacy on remote device. +** Parameters: privacy_enable - enable/disable privacy on remote device. ** set_local_privacy_cback -callback to be called with result ** Returns void ** @@ -2585,7 +2587,7 @@ extern void BTA_DmBleConfigLocalIcon(uint16_t icon); ** Description Enable/disable privacy on a remote device ** ** Parameters: bd_addr - BD address of the peer -** privacy_enable - enable/disabe privacy on remote device. +** privacy_enable - enable/disable privacy on remote device. ** ** Returns void ** diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index 33e5c2952a..a88a39680d 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -884,6 +884,21 @@ static void btc_set_local_privacy_callback(UINT8 status) } } +static void btc_set_rpa_timeout_callback(UINT8 status) +{ + esp_ble_gap_cb_param_t param; + bt_status_t ret; + btc_msg_t msg = {0}; + msg.sig = BTC_SIG_API_CB; + msg.pid = BTC_PID_GAP_BLE; + msg.act = ESP_GAP_BLE_SET_RPA_TIMEOUT_COMPLETE_EVT; + param.set_rpa_timeout_cmpl.status = btc_btm_status_to_esp_status(status); + ret = btc_transfer_context(&msg, ¶m, + sizeof(esp_ble_gap_cb_param_t), NULL, NULL); + if (ret != BT_STATUS_SUCCESS) { + BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); + } +} #if (SMP_INCLUDED == TRUE) static void btc_set_encryption_callback(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS enc_status) @@ -1398,6 +1413,11 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK * } } +static void btc_ble_set_rpa_timeout(uint16_t rpa_timeout,tBTA_SET_RPA_TIMEOUT_CMPL_CBACK *set_rpa_timeout_cback) +{ + BTA_DmBleSetRpaTimeout(rpa_timeout,set_rpa_timeout_cback); +} + static void btc_ble_clear_rand_addr (void) { BTA_DmClearRandAddress(); @@ -1458,7 +1478,7 @@ void btc_gap_ble_cb_handler(btc_msg_t *msg) if (msg->act < ESP_GAP_BLE_EVT_MAX) { btc_gap_ble_cb_to_app(msg->act, param); } else { - BTC_TRACE_ERROR("%s, unknow msg->act = %d", __func__, msg->act); + BTC_TRACE_ERROR("%s, unknown msg->act = %d", __func__, msg->act); } btc_gap_ble_cb_deep_free(msg); @@ -1852,6 +1872,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_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT: { + btc_ble_set_rpa_timeout(arg->set_rpa_timeout.rpa_timeout,btc_set_rpa_timeout_callback); + break; + } case BTC_GAP_BLE_ACT_CLEAR_RAND_ADDRESS: { btc_ble_clear_rand_addr(); break; diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index 71d89359d9..7ac0b12f47 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -103,6 +103,7 @@ typedef enum { BTC_GAP_BLE_ACT_CLEAR_ADV, #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT, + BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT, } btc_gap_ble_act_t; /* btc_ble_gap_args_t */ @@ -140,6 +141,10 @@ typedef union { struct set_rand_addr_args { esp_bd_addr_t rand_addr; } set_rand_addr; + // BTC_GAP_BLE_ACT_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT + struct set_rpa_timeout_args { + uint16_t rpa_timeout; + } set_rpa_timeout; //BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY, struct cfg_local_privacy_args { bool privacy_enable; diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 7dad8217a2..b74f404200 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -1333,7 +1333,7 @@ tBTM_STATUS BTM_BleSetConnectableMode(tBTM_BLE_CONN_MODE connectable_mode) ** ** Function btm_set_conn_mode_adv_init_addr ** -** Description set initator address type and local address type based on adv +** Description set initiator address type and local address type based on adv ** mode. ** ** @@ -2001,7 +2001,7 @@ tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr) } if (btm_cb.ble_ctr_cb.inq_var.state != BTM_BLE_IDLE) { - BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state); + BTM_TRACE_ERROR("Advertising or scanning 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); @@ -2030,7 +2030,7 @@ 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_IDLE)) { - BTM_TRACE_ERROR("Advertising or scaning now, can't restore public address "); + BTM_TRACE_ERROR("Advertising or scanning now, can't restore public address "); return; } memset(btm_cb.ble_ctr_cb.addr_mgnt_cb.static_rand_addr, 0, BD_ADDR_LEN); @@ -3729,7 +3729,7 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt /* never been report as an LE device */ if (p_i && (!(p_i->inq_info.results.device_type & BT_DEVICE_TYPE_BLE) || - /* scan repsonse to be updated */ + /* scan response to be updated */ (!p_i->scan_rsp))) { update = TRUE; } else if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) { @@ -4003,7 +4003,7 @@ static void btm_ble_stop_discover(void) ** ** Description Set or clear adv states in topology mask ** -** Returns operation status. TRUE if sucessful, FALSE otherwise. +** Returns operation status. TRUE if successful, FALSE otherwise. ** *******************************************************************************/ typedef BOOLEAN (BTM_TOPOLOGY_FUNC_PTR)(tBTM_BLE_STATE_MASK); @@ -4264,7 +4264,7 @@ void btm_ble_timeout(TIMER_LIST_ENT *p_tle) break; case BTU_TTYPE_BLE_GAP_LIM_DISC: - /* lim_timeout expiried, limited discovery should exit now */ + /* lim_timeout expired, limited discovery should exit now */ btm_cb.btm_inq_vars.discoverable_mode &= ~BTM_BLE_LIMITED_DISCOVERABLE; btm_ble_set_adv_flag(btm_cb.btm_inq_vars.connectable_mode, btm_cb.btm_inq_vars.discoverable_mode); break; @@ -4703,6 +4703,15 @@ BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback) p_cb->inq_var.p_clear_adv_cb = p_clear_adv_cback; return TRUE; } +BOOLEAN BTM_BleSetRpaTimeout(uint16_t rpa_timeout,tBTM_SET_RPA_TIMEOUT_CMPL_CBACK *p_set_rpa_timeout_cback) +{ + if ((btsnd_hcic_ble_set_rand_priv_addr_timeout(rpa_timeout)) != TRUE) { + BTM_TRACE_ERROR("Set RPA Timeout error, rpa_timeout:0x%04x",rpa_timeout); + return FALSE; + } + btm_cb.devcb.p_ble_set_rpa_timeout_cmpl_cb = p_set_rpa_timeout_cback; + return TRUE; +} bool btm_ble_adv_pkt_ready(void) { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c index 7058df20fc..546eff3d47 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c @@ -416,6 +416,36 @@ void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len) random_cb->set_local_privacy_cback(BTM_ILLEGAL_VALUE); } +/******************************************************************************* +** +** Function btm_ble_set_rpa_timeout_complete +** +** Description This function is called when the LE Set Resolvable Private +** Address Timeout command completes. +** +** Parameters p: Pointer to the command complete event data. +** evt_len: Length of the event data. +** +** Returns void +** +*******************************************************************************/ +void btm_ble_set_rpa_timeout_complete(UINT8 *p, UINT16 evt_len) +{ + UINT8 status; + + // Extract the status of the command completion from the event data + STREAM_TO_UINT8(status, p); + + 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); + } + +} + /******************************************************************************* VSC that implement controller based privacy ********************************************************************************/ @@ -459,7 +489,7 @@ void btm_ble_resolving_list_vsc_op_cmpl (tBTM_VSC_CMPL *p_params) ** Description This function to remove an IRK entry from the list ** ** Parameters ble_addr_type: address type -** ble_addr: LE adddress +** ble_addr: LE address ** ** Returns status ** @@ -949,7 +979,7 @@ void btm_ble_enable_resolving_list(UINT8 rl_mask) ** ** Function btm_ble_resolving_list_empty ** -** Description check to see if resoving list is empty or not +** Description check to see if resolving list is empty or not ** ** Returns TRUE: empty; FALSE non-empty ** @@ -1074,7 +1104,7 @@ void btm_ble_add_default_entry_to_resolving_list(void) /* * Add local IRK entry with 00:00:00:00:00:00 address. This entry will * be used to generate RPA for non-directed advertising if own_addr_type - * is set to rpa_pub since we use all-zero address as peer addres in + * is set to rpa_pub since we use all-zero address as peer address in * such case. Peer IRK should be left all-zero since this is not for an * actual peer. */ diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index 1f55289c75..dd42cefcac 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -313,7 +313,7 @@ typedef struct { #define BTM_PRIVACY_NONE 0 /* BLE no privacy */ #define BTM_PRIVACY_1_1 1 /* BLE privacy 1.1, do not support privacy 1.0 */ #define BTM_PRIVACY_1_2 2 /* BLE privacy 1.2 */ -#define BTM_PRIVACY_MIXED 3 /* BLE privacy mixed mode, broadcom propietary mode */ +#define BTM_PRIVACY_MIXED 3 /* BLE privacy mixed mode, broadcom proprietary mode */ typedef UINT8 tBTM_PRIVACY_MODE; /* data length change event callback */ @@ -486,6 +486,7 @@ void btm_ble_refresh_peer_resolvable_private_addr(BD_ADDR pseudo_bda, BD_ADDR rr void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr, BD_ADDR local_rpa); void btm_ble_read_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len) ; void btm_ble_set_addr_resolution_enable_complete(UINT8 *p, UINT16 evt_len) ; +void btm_ble_set_rpa_timeout_complete(UINT8 *p, UINT16 evt_len) ; void btm_ble_remove_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len); void btm_ble_add_resolving_list_entry_complete(UINT8 *p, UINT16 evt_len); void btm_ble_clear_resolving_list_complete(UINT8 *p, UINT16 evt_len); diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 8d1db68b55..3109240771 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -228,6 +228,9 @@ 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_CMPL_CB *p_le_test_cmd_cmpl_cb; /* Callback function to be called when LE test mode command has been sent successfully */ @@ -351,7 +354,7 @@ typedef struct { UINT8 inqfilt_type; /* Contains the inquiry filter type (BD ADDR, COD, or Clear) */ #define BTM_INQ_INACTIVE_STATE 0 -#define BTM_INQ_CLR_FILT_STATE 1 /* Currently clearing the inquiry filter preceeding the inquiry request */ +#define BTM_INQ_CLR_FILT_STATE 1 /* Currently clearing the inquiry filter preceding the inquiry request */ /* (bypassed if filtering is not used) */ #define BTM_INQ_SET_FILT_STATE 2 /* Sets the new filter (or turns off filtering) in this state */ #define BTM_INQ_ACTIVE_STATE 3 /* Actual inquiry or periodic inquiry is in progress */ @@ -942,8 +945,8 @@ typedef struct { UINT8 acl_disc_reason; UINT8 trace_level; UINT8 busy_level; /* the current busy level */ - BOOLEAN is_paging; /* TRUE, if paging is in progess */ - BOOLEAN is_inquiry; /* TRUE, if inquiry is in progess */ + BOOLEAN is_paging; /* TRUE, if paging is in progress */ + BOOLEAN is_inquiry; /* TRUE, if inquiry is in progress */ fixed_queue_t *page_queue; BOOLEAN paging; BOOLEAN discing; diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 8216a2ac3b..3d9122940c 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -1089,6 +1089,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_ble_set_addr_resolution_enable_complete(p, evt_len); break; case HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT: + btm_ble_set_rpa_timeout_complete(p, evt_len); break; #if (BLE_50_FEATURE_SUPPORT == TRUE) case HCI_BLE_SET_EXT_ADV_PARAM: diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index 523af8ed63..7b28e6a1f8 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -197,7 +197,7 @@ typedef void (tBTM_UPDATE_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_o typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status); - +typedef void (tBTM_SET_RPA_TIMEOUT_CMPL_CBACK) (UINT8 status); /***************************************************************************** ** DEVICE DISCOVERY - Inquiry, Remote Name, Discovery, Class of Device *****************************************************************************/ @@ -308,7 +308,7 @@ typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status); #define BTM_COD_MINOR_CELLULAR 0x04 #define BTM_COD_MINOR_CORDLESS 0x08 #define BTM_COD_MINOR_SMART_PHONE 0x0C -#define BTM_COD_MINOR_WIRED_MDM_V_GTWY 0x10 /* wired modem or voice gatway */ +#define BTM_COD_MINOR_WIRED_MDM_V_GTWY 0x10 /* wired modem or voice gateway */ #define BTM_COD_MINOR_ISDN_ACCESS 0x14 /* minor device class field for LAN Access Point Major Class */ @@ -1549,7 +1549,7 @@ typedef struct { tBTM_AUTH_REQ loc_auth_req; /* Authentication required for local device */ tBTM_AUTH_REQ rmt_auth_req; /* Authentication required for peer device */ tBTM_IO_CAP loc_io_caps; /* IO Capabilities of the local device */ - tBTM_IO_CAP rmt_io_caps; /* IO Capabilities of the remot device */ + tBTM_IO_CAP rmt_io_caps; /* IO Capabilities of the remote device */ } tBTM_SP_CFM_REQ; /* data type for BTM_SP_KEY_REQ_EVT */ @@ -2206,7 +2206,7 @@ UINT8 BTM_SetTraceLevel (UINT8 new_level); ** ** Function BTM_WritePageTimeout ** -** Description Send HCI Wite Page Timeout. +** Description Send HCI Write Page Timeout. ** ** Returns ** BTM_SUCCESS Command sent. @@ -2384,7 +2384,7 @@ tBTM_STATUS BTM_StartInquiry (tBTM_INQ_PARMS *p_inqparms, ** Description This function returns a bit mask of the current inquiry state ** ** Returns BTM_INQUIRY_INACTIVE if inactive (0) -** BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active +** BTM_LIMITED_INQUIRY_ACTIVE if a limited inquiry is active ** BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active ** BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active ** @@ -3524,7 +3524,7 @@ BOOLEAN BTM_SecAddDevice (BD_ADDR bd_addr, DEV_CLASS dev_class, ** ** Description Free resources associated with the device. ** -** Returns TRUE if rmoved OK, FALSE if not found +** Returns TRUE if removed OK, FALSE if not found ** *******************************************************************************/ //extern @@ -4170,7 +4170,7 @@ UINT8 BTM_GetEirUuidList( UINT8 *p_eir, UINT8 uuid_size, UINT8 *p_num_uuid, ** pointer is used, PCM parameter maintained in ** the control block will be used; otherwise update ** control block value. -** err_data_rpt: Lisbon feature to enable the erronous data report +** err_data_rpt: Lisbon feature to enable the erroneous data report ** or not. ** ** Returns BTM_SUCCESS if the successful. diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index ab2997a8f7..44aba3cc7b 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -144,12 +144,12 @@ typedef UINT8 tBTM_BLE_SFP; #ifndef BTM_BLE_SCAN_FAST_INT #define BTM_BLE_SCAN_FAST_INT 96 /* 30 ~ 60 ms (use 60) = 96 *0.625 */ #endif -/* default scan window for background connection, applicable for auto connection or selective conenction */ +/* default scan window for background connection, applicable for auto connection or selective connection */ #ifndef BTM_BLE_SCAN_FAST_WIN #define BTM_BLE_SCAN_FAST_WIN 48 /* 30 ms = 48 *0.625 */ #endif -/* default scan paramter used in reduced power cycle (background scanning) */ +/* default scan parameter used in reduced power cycle (background scanning) */ #ifndef BTM_BLE_SCAN_SLOW_INT_1 #define BTM_BLE_SCAN_SLOW_INT_1 2048 /* 1.28 s = 2048 *0.625 */ #endif @@ -157,7 +157,7 @@ typedef UINT8 tBTM_BLE_SFP; #define BTM_BLE_SCAN_SLOW_WIN_1 48 /* 30 ms = 48 *0.625 */ #endif -/* default scan paramter used in reduced power cycle (background scanning) */ +/* default scan parameter used in reduced power cycle (background scanning) */ #ifndef BTM_BLE_SCAN_SLOW_INT_2 #define BTM_BLE_SCAN_SLOW_INT_2 4096 /* 2.56 s = 4096 *0.625 */ #endif @@ -460,7 +460,7 @@ typedef struct { } tBTM_BLE_PROPRIETARY; typedef struct { - tBTM_BLE_INT_RANGE int_range; /* slave prefered conn interval range */ + tBTM_BLE_INT_RANGE int_range; /* slave preferred conn interval range */ tBTM_BLE_MANU *p_manu; /* manufacturer data */ tBTM_BLE_SERVICE *p_services; /* services */ tBTM_BLE_128SERVICE *p_services_128b; /* 128 bits service */ @@ -1895,7 +1895,7 @@ void BTM_BleSecureConnectionCreateOobData(void); ** Function BTM_BleDataSignature ** ** Description This function is called to sign the data using AES128 CMAC -** algorith. +** algorithm. ** ** Parameter bd_addr: target device the data to be signed for. ** p_text: singing data @@ -1903,7 +1903,7 @@ void BTM_BleSecureConnectionCreateOobData(void); ** signature: output parameter where data signature is going to ** be stored. ** -** Returns TRUE if signing sucessul, otherwise FALSE. +** Returns TRUE if signing successful, otherwise FALSE. ** *******************************************************************************/ //extern @@ -2393,7 +2393,7 @@ BOOLEAN BTM_UseLeLink (BD_ADDR bd_addr); ** ** Function BTM_BleStackEnable ** -** Description Enable/Disable BLE functionality on stack regarless controller +** Description Enable/Disable BLE functionality on stack regardless controller ** capability. ** ** Parameters: enable: TRUE to enable, FALSE to disable. @@ -2437,7 +2437,7 @@ BOOLEAN BTM_BleSecurityProcedureIsRunning (BD_ADDR bd_addr); ** Function BTM_BleGetSupportedKeySize ** ** Description This function gets the maximum encryption key size in bytes -** the local device can suport. +** the local device can support. ** record. ** ** Returns the key size or 0 if the size can't be retrieved. @@ -2472,7 +2472,7 @@ tBTM_STATUS BTM_BleEnableAdvInstance (tBTM_BLE_ADV_PARAMS *p_params, ** ** Function BTM_BleUpdateAdvInstParam ** -** Description This function update a Multi-ADV instance with the specififed +** Description This function update a Multi-ADV instance with the specified ** adv parameters. ** ** Parameters inst_id: adv instance ID @@ -2548,7 +2548,7 @@ tBTM_STATUS BTM_BleAdvFilterParamSetup(int action, ** ** Parameters action: to read/write/clear ** cond_type: filter condition type. -** p_cond: filter condition paramter +** p_cond: filter condition parameter ** ** Returns tBTM_STATUS ** @@ -2655,6 +2655,19 @@ BOOLEAN BTM_Ble_Authorization(BD_ADDR bd_addr, BOOLEAN authorize); ** *******************************************************************************/ BOOLEAN BTM_BleClearAdv(tBTM_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback); + +/******************************************************************************* +** +** Function BTM_BleSetRpaTimeout +** +** Description This function is called to set the Resolvable Private Address +** (RPA) timeout. +** +** 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); + /* #ifdef __cplusplus }