aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-09-18 13:36:07 +0200
committerSven Gothel <[email protected]>2021-09-18 13:36:07 +0200
commit62e7ad58c1fe252fcc3fbf75c6ac8400f0cfa44d (patch)
tree728bb37349fd0c25347891140c9d46fd8f77780b
parente85294259d8f535444463e2550ecad59a8305bee (diff)
BTDevice::connectLE: Allow explicit connect request to BLERandomAddressType [UNRESOLVABLE_PRIVAT and RESOLVABLE_PRIVAT]
Since we do not resolve the RESOLVABLE_PRIVAT using an IRK, we simply set the HCILEPeerAddressType to RANDOM for all BDAddressType::BDADDR_LE_RANDOM peers. HCILEOwnAddressType is always PUBLIC, as we do not support 'LE Set Privacy Mode' yet. This at least seems to work OK for BLERandomAddressType::UNRESOLVABLE_PRIVAT.
-rw-r--r--src/direct_bt/BTDevice.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 1b68e84b..843f137c 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -301,35 +301,28 @@ HCIStatusCode BTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_wi
WARN_PRINT("BTDevice::connectLE: Adapter not powered: %s, %s", adapter.toString().c_str(), toString().c_str());
return HCIStatusCode::NOT_POWERED;
}
- HCILEOwnAddressType hci_own_mac_type;
+ HCILEOwnAddressType hci_own_mac_type = HCILEOwnAddressType::PUBLIC;
HCILEPeerAddressType hci_peer_mac_type;
switch( addressAndType.type ) {
case BDAddressType::BDADDR_LE_PUBLIC:
hci_peer_mac_type = HCILEPeerAddressType::PUBLIC;
- hci_own_mac_type = HCILEOwnAddressType::PUBLIC;
break;
case BDAddressType::BDADDR_LE_RANDOM: {
+ // TODO: Shall we support 'resolving list' and/or LE Set Privacy Mode (HCI) ?
const BLERandomAddressType leRandomAddressType = addressAndType.getBLERandomAddressType();
switch( leRandomAddressType ) {
case BLERandomAddressType::UNRESOLVABLE_PRIVAT:
+ // TODO: OK to not be able to resolve?
hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
- hci_own_mac_type = HCILEOwnAddressType::RANDOM;
- ERR_PRINT("LE Random address type '%s' not supported yet: %s",
- to_string(leRandomAddressType).c_str(), toString().c_str());
- return HCIStatusCode::UNACCEPTABLE_CONNECTION_PARAM;
+ break;
case BLERandomAddressType::RESOLVABLE_PRIVAT:
- hci_peer_mac_type = HCILEPeerAddressType::PUBLIC_IDENTITY;
- hci_own_mac_type = HCILEOwnAddressType::RESOLVABLE_OR_PUBLIC;
- ERR_PRINT("LE Random address type '%s' not supported yet: %s",
- to_string(leRandomAddressType).c_str(), toString().c_str());
- return HCIStatusCode::UNACCEPTABLE_CONNECTION_PARAM;
+ // TODO: Shall we resolve this address using IRK to set HCILEPeerAddressType::PUBLIC_IDENTITY ?
+ hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
+ break;
case BLERandomAddressType::STATIC_PUBLIC:
- // FIXME: This only works for a static random address not changing at all,
- // i.e. between power-cycles - hence a temporary hack.
- // We need to use 'resolving list' and/or LE Set Privacy Mode (HCI) for all devices.
+ // Static random address is not changing between power-cycles.
hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
- hci_own_mac_type = HCILEOwnAddressType::PUBLIC;
break;
default: {
ERR_PRINT("Can't connectLE to LE Random address type '%s': %s",