Expose API to set RPA Timeout

This commit is contained in:
Rahul Tank
2024-04-23 12:01:28 +05:30
parent 03b259130c
commit e1885a83fa
2 changed files with 30 additions and 1 deletions
+2
View File
@@ -70,6 +70,8 @@ void ble_hs_resolv_deinit(void);
int ble_hs_pvcy_set_resolve_enabled(int enable);
void ble_hs_set_rpa_timeout(uint16_t timeout);
#ifdef __cplusplus
}
#endif
+28 -1
View File
@@ -32,6 +32,7 @@ const uint8_t ble_hs_pvcy_default_irk[16] = {
0xef, 0x8d, 0xe2, 0x16, 0x4f, 0xec, 0x43, 0x0d,
0xbf, 0x5b, 0xdd, 0x34, 0xc0, 0x53, 0x1e, 0xb8,
};
uint16_t rpa_timeout;
static int
ble_hs_pvcy_set_addr_timeout(uint16_t timeout)
@@ -53,6 +54,23 @@ ble_hs_pvcy_set_addr_timeout(uint16_t timeout)
&cmd, sizeof(cmd), NULL, 0);
}
void ble_hs_set_rpa_timeout (uint16_t timeout)
{
rpa_timeout = timeout;
ble_hs_pvcy_set_addr_timeout(rpa_timeout);
}
uint16_t ble_hs_get_rpa_timeout(void)
{
return rpa_timeout;
}
void ble_hs_reset_rpa_timeout(void)
{
rpa_timeout = 0 ;
}
#if (!MYNEWT_VAL(BLE_HOST_BASED_PRIVACY))
int
ble_hs_pvcy_set_resolve_enabled(int enable)
@@ -182,6 +200,7 @@ int
ble_hs_pvcy_ensure_started(void)
{
int rc;
uint16_t rpa_timeout;
if (ble_hs_pvcy_started) {
return 0;
@@ -192,8 +211,16 @@ ble_hs_pvcy_ensure_started(void)
ble_hs_resolv_init();
#endif
/* Check if user has already set any timeout. If yes, use it */
rpa_timeout = ble_hs_get_rpa_timeout();
/* Set up the periodic change of our RPA. */
rc = ble_hs_pvcy_set_addr_timeout(MYNEWT_VAL(BLE_RPA_TIMEOUT));
if (rpa_timeout) {
rc = ble_hs_pvcy_set_addr_timeout(rpa_timeout);
} else {
rc = ble_hs_pvcy_set_addr_timeout(MYNEWT_VAL(BLE_RPA_TIMEOUT));
}
if (rc != 0) {
return rc;
}