From 367707a1586e123a8be61c6c49034b68a0db4ece Mon Sep 17 00:00:00 2001 From: Gunar Schorcht Date: Thu, 18 Aug 2022 18:43:31 +0200 Subject: [PATCH] pkg/nimble: derive used address type in statconn from peer address Using a `BLE_ADDR_RANDOM` as the peer address type allows connecting only to peers that have a static random address. Deriving the peer address type from the peer address is simple and allows connections to be established with peers that have either a public or static random address. --- pkg/nimble/statconn/nimble_statconn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/nimble/statconn/nimble_statconn.c b/pkg/nimble/statconn/nimble_statconn.c index 01dc5e0156..d35a5a656c 100644 --- a/pkg/nimble/statconn/nimble_statconn.c +++ b/pkg/nimble/statconn/nimble_statconn.c @@ -86,7 +86,8 @@ static void _activate(uint8_t role) if (slot && (role == ROLE_M)) { ble_addr_t peer; - peer.type = BLE_ADDR_RANDOM; + peer.type = ((slot->addr[0] & 0xc0) == 0xc0) ? BLE_ADDR_RANDOM + : BLE_ADDR_PUBLIC; bluetil_addr_swapped_cp(slot->addr, peer.val); /* try to (re)open the connection */ #if IS_USED(MODULE_NIMBLE_STATCONN_EXT)