1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

pkt/nimble/statconn: use netifs rand conn intervals

This commit is contained in:
Hauke Petersen 2021-04-21 20:34:31 +02:00
parent 402bd20ec9
commit 2a0f1ac634

View File

@ -27,14 +27,10 @@
#include "host/ble_hs.h"
#if NIMBLE_STATCONN_CONN_ITVL_MIN_MS != NIMBLE_STATCONN_CONN_ITVL_MAX_MS
#include "random.h"
/* sanity check on the conn interval range to catch configuration errors */
#if NIMBLE_STATCONN_CONN_ITVL_MIN_MS > NIMBLE_STATCONN_CONN_ITVL_MAX_MS
#error "nimble_statconn: CONN_ITVL_MIN_MS must be <= CONN_ITVL_MAX_MS"
#endif
#endif
#define ENABLE_DEBUG 0
#include "debug.h"
@ -91,16 +87,6 @@ static void _activate(uint8_t role)
ble_addr_t peer;
peer.type = BLE_ADDR_RANDOM;
bluetil_addr_swapped_cp(slot->addr, peer.val);
/* compute a random new random connection interval if configured */
#if NIMBLE_STATCONN_CONN_ITVL_MIN_MS != NIMBLE_STATCONN_CONN_ITVL_MAX_MS
uint32_t itvl = random_uint32_range(NIMBLE_STATCONN_CONN_ITVL_MIN_MS,
NIMBLE_STATCONN_CONN_ITVL_MAX_MS);
_conn_params.itvl_min = BLE_GAP_CONN_ITVL_MS(itvl);
#else
_conn_params.itvl_min = BLE_GAP_CONN_ITVL_MS(
NIMBLE_STATCONN_CONN_ITVL_MIN_MS);
#endif
_conn_params.itvl_max = _conn_params.itvl_min;
/* try to (re)open the connection */
nimble_netif_connect(&peer, &_conn_params, _conn_timeout);
}
@ -208,6 +194,10 @@ void nimble_statconn_init(void)
_conn_params.latency = NIMBLE_STATCONN_CONN_LATENCY;
_conn_params.supervision_timeout = BLE_GAP_SUPERVISION_TIMEOUT_MS(
NIMBLE_STATCONN_CONN_SUPERTO_MS);
_conn_params.itvl_min = BLE_GAP_CONN_ITVL_MS(
NIMBLE_STATCONN_CONN_ITVL_MIN_MS);
_conn_params.itvl_max = BLE_GAP_CONN_ITVL_MS(
NIMBLE_STATCONN_CONN_ITVL_MAX_MS);
_conn_params.min_ce_len = 0;
_conn_params.max_ce_len = 0;
_conn_timeout = NIMBLE_STATCONN_CONN_TIMEOUT_MS;