p_cb->own_addr_type = BLE_ADDR_RANDOM;
/* start a periodical timer to refresh random addr */
- uint64_t interval_ms = BTM_BLE_PRIVATE_ADDR_INT_MS;
+ uint64_t interval_ms = btm_get_next_private_addrress_interval_ms();
#if (BTM_BLE_CONFORMANCE_TESTING == TRUE)
interval_ms = btm_cb.ble_ctr_cb.rpa_tout * 1000;
#endif
std::move(cb)));
}
+uint64_t btm_get_next_private_addrress_interval_ms() {
+ /* 7 minutes minimum, 15 minutes maximum for random address refreshing */
+ const uint64_t interval_min_ms = (7 * 60 * 1000);
+ const uint64_t interval_random_part_max_ms = (8 * 60 * 1000);
+
+ return interval_min_ms + std::rand() % interval_random_part_max_ms;
+}
+
/*******************************************************************************
*
* Function btm_gen_non_resolve_paddr_cmpl
extern tBTM_SEC_DEV_REC* btm_ble_resolve_random_addr(
const RawAddress& random_bda);
extern void btm_gen_resolve_paddr_low(const RawAddress& address);
+extern uint64_t btm_get_next_private_addrress_interval_ms();
/* privacy function */
#if (BLE_PRIVACY_SPT == TRUE)
#define BTM_BLE_ISVALID_PARAM(x, min, max) \
(((x) >= (min) && (x) <= (max)) || ((x) == BTM_BLE_CONN_PARAM_UNDEF))
-/* 15 minutes minimum for random address refreshing */
-#define BTM_BLE_PRIVATE_ADDR_INT_MS (15 * 60 * 1000)
-
typedef struct {
uint16_t discoverable_mode;
uint16_t connectable_mode;
#include "ble_advertiser.h"
#include "ble_advertiser_hci_interface.h"
#include "btm_int_types.h"
+#include "stack/btm/btm_ble_int.h"
#include <string.h>
#include <queue>
p_inst->own_address = bda;
alarm_set_on_mloop(p_inst->adv_raddr_timer,
- BTM_BLE_PRIVATE_ADDR_INT_MS,
+ btm_get_next_private_addrress_interval_ms(),
btm_ble_adv_raddr_timer_timeout, p_inst);
cb.Run(p_inst->inst_id, BTM_BLE_MULTI_ADV_SUCCESS);
},
l2c_link_processs_num_bufs(controller->get_acl_buffer_count_classic());
+ // setup the random number generator
+ std::srand(std::time(nullptr));
+
#if (BLE_PRIVACY_SPT == TRUE)
/* Set up the BLE privacy settings */
if (controller->supports_ble() && controller->supports_ble_privacy() &&
controller->get_ble_resolving_list_max_size() > 0) {
btm_ble_resolving_list_init(controller->get_ble_resolving_list_max_size());
/* set the default random private address timeout */
- btsnd_hcic_ble_set_rand_priv_addr_timeout(BTM_BLE_PRIVATE_ADDR_INT_MS /
- 1000);
+ btsnd_hcic_ble_set_rand_priv_addr_timeout(
+ btm_get_next_private_addrress_interval_ms() / 1000);
}
#endif
void alarm_free(alarm_t* alarm) {}
const controller_t* controller_get_interface() { return nullptr; }
+uint64_t btm_get_next_private_addrress_interval_ms() { return 15 * 60 * 1000; }
+
namespace {
void DoNothing(uint8_t) {}