summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-10-22 05:32:36 +0200
committerSven Gothel <[email protected]>2023-10-22 05:32:36 +0200
commitfec99c59a6b638b17f827e5bfd3539f27190448b (patch)
tree1d379f09df3841e32d3ab811985ac84a5bf87d84 /src
parent74af7dc765d9402d92aebebce350ad3f5beaaee2 (diff)
Adapter Random Address: Add visibleMACType = HCILEOwnAddressType::PUBLIC and use it for BTAdapter::startDiscovery() and BTDevice::connectLE()
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/BTAdapter.cpp6
-rw-r--r--src/direct_bt/BTDevice.cpp2
-rw-r--r--src/direct_bt/BTTypes0.cpp4
3 files changed, 5 insertions, 7 deletions
diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp
index 59ee6da2..6ba8f67c 100644
--- a/src/direct_bt/BTAdapter.cpp
+++ b/src/direct_bt/BTAdapter.cpp
@@ -380,6 +380,7 @@ BTAdapter::BTAdapter(const BTAdapter::ctor_cookie& cc, BTManagerRef mgmt_, Adapt
le_features( LE_Features::NONE ),
hci_uses_ext_scan( false ), hci_uses_ext_conn( false ), hci_uses_ext_adv( false ),
visibleAddressAndType( adapterInfo_.addressAndType ),
+ visibleMACType( HCILEOwnAddressType::PUBLIC ),
dev_id( adapterInfo.dev_id ),
btRole ( BTRole::Master ),
hci( dev_id ),
@@ -1124,11 +1125,8 @@ HCIStatusCode BTAdapter::startDiscovery(const DiscoveryPolicy policy, const bool
discovery_policy = policy;
- // TODO: Potential changing adapter address mode to random and updating 'visibleAddressAndType'!
- const BDAddressType usedAddrType = BDAddressType::BDADDR_LE_PUBLIC;
- const HCILEOwnAddressType own_mac_type=to_HCILEOwnAddressType(usedAddrType);
// if le_enable_scan(..) is successful, it will issue 'mgmtEvDeviceDiscoveringHCI(..)' immediately, which updates currentMetaScanType.
- const HCIStatusCode status = hci.le_start_scan(filter_dup, le_scan_active, own_mac_type,
+ const HCIStatusCode status = hci.le_start_scan(filter_dup, le_scan_active, visibleMACType,
le_scan_interval, le_scan_window, filter_policy);
if( _print_device_lists || jau::environment::get().verbose ) {
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 28b03ea8..876463ed 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -300,7 +300,7 @@ HCIStatusCode BTDevice::connectLE(const uint16_t le_scan_interval, const uint16_
WARN_PRINT("Adapter not powered: %s, %s", adapter.toString().c_str(), toString().c_str());
return HCIStatusCode::NOT_POWERED;
}
- HCILEOwnAddressType hci_own_mac_type = HCILEOwnAddressType::PUBLIC;
+ HCILEOwnAddressType hci_own_mac_type = adapter.visibleMACType;
HCILEPeerAddressType hci_peer_mac_type;
switch( addressAndType.type ) {
diff --git a/src/direct_bt/BTTypes0.cpp b/src/direct_bt/BTTypes0.cpp
index 2c52b444..00b0fe36 100644
--- a/src/direct_bt/BTTypes0.cpp
+++ b/src/direct_bt/BTTypes0.cpp
@@ -96,14 +96,14 @@ BDAddressType direct_bt::to_BDAddressType(const HCILEOwnAddressType hciOwnAddrTy
}
}
-HCILEOwnAddressType direct_bt::to_HCILEOwnAddressType(const BDAddressType addrType) noexcept {
+HCILEOwnAddressType direct_bt::to_HCILEOwnAddressType(const BDAddressType addrType, bool resolvable) noexcept {
switch(addrType) {
case BDAddressType::BDADDR_LE_PUBLIC:
return HCILEOwnAddressType::PUBLIC;
case BDAddressType::BDADDR_LE_RANDOM:
/** FIXME: Sufficient mapping for adapter put in random address mode? */
- return HCILEOwnAddressType::RANDOM;
+ return resolvable ? HCILEOwnAddressType::RESOLVABLE_OR_RANDOM : HCILEOwnAddressType::RANDOM;
case BDAddressType::BDADDR_BREDR:
[[fallthrough]];