aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-07-02 07:46:19 +0200
committerSven Gothel <[email protected]>2020-07-02 07:46:19 +0200
commit613fbbef65c4d9593c97fb84d3b6a0e27037f9bf (patch)
tree4d9088252ea626e516e9344ec0ac05fe4d8f3b9c /src
parentc92aec05cbea8703a23bc5827680dd6e7a787e55 (diff)
Support BDADDR_LE_RANDOM (p1.2): Map BLERandomAddressType::STATIC_PUBLIC -> RANDOM; L2CAPComm uses device->getAddressType()
Map BLERandomAddressType::STATIC_PUBLIC -> HCILEPeerAddressType::RANDOM 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. +++ L2CAPComm uses device->getAddressType(), i.e. no need for a (wrong) public argument flag.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/DBTDevice.cpp17
-rw-r--r--src/direct_bt/L2CAPComm.cpp6
2 files changed, 14 insertions, 9 deletions
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp
index 3dc1ac91..7e5f723d 100644
--- a/src/direct_bt/DBTDevice.cpp
+++ b/src/direct_bt/DBTDevice.cpp
@@ -254,29 +254,34 @@ bool DBTDevice::connectLE(uint16_t le_scan_interval, uint16_t le_scan_window,
{
const std::lock_guard<std::recursive_mutex> lock_conn(mtx_connect); // RAII-style acquire and relinquish via destructor
- const HCILEOwnAddressType hci_own_mac_type = HCILEOwnAddressType::PUBLIC; // FIXME: Support non public address-type for adapter?
-
+ HCILEOwnAddressType hci_own_mac_type;
HCILEPeerAddressType hci_peer_mac_type;
switch( addressType ) {
case BDAddressType::BDADDR_LE_PUBLIC:
hci_peer_mac_type = HCILEPeerAddressType::PUBLIC;
+ hci_own_mac_type = HCILEOwnAddressType::PUBLIC;
break;
case BDAddressType::BDADDR_LE_RANDOM: {
switch( leRandomAddressType ) {
case BLERandomAddressType::UNRESOLVABLE_PRIVAT:
- // hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
+ hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
+ hci_own_mac_type = HCILEOwnAddressType::RANDOM;
ERR_PRINT("LE Random address type '%s' not supported yet: %s",
getBLERandomAddressTypeString(leRandomAddressType).c_str(), toString().c_str());
return false;
case BLERandomAddressType::RESOLVABLE_PRIVAT:
- // hci_peer_mac_type = HCILEPeerAddressType::RANDOM;
+ 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",
getBLERandomAddressTypeString(leRandomAddressType).c_str(), toString().c_str());
return false;
case BLERandomAddressType::STATIC_PUBLIC:
- // FIXME: Even though HCI_LE_SetPrivacy_mode is advised if supported by both.
- hci_peer_mac_type = HCILEPeerAddressType::RANDOM_STATIC_IDENTITY;
+ // 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.
+ 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",
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index d974d35a..b7054f67 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -97,8 +97,8 @@ int L2CAPComm::l2cap_close_dev(int dd)
// *************************************************
// *************************************************
-L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device, const uint16_t psm, const uint16_t cid, const bool pubaddr)
-: device(device), deviceString(device->getAddressString()), psm(psm), cid(cid), pubaddr(pubaddr),
+L2CAPComm::L2CAPComm(std::shared_ptr<DBTDevice> device, const uint16_t psm, const uint16_t cid)
+: device(device), deviceString(device->getAddressString()), psm(psm), cid(cid),
_dd(-1), isConnected(false), hasIOError(false), interruptFlag(false), tid_connect(0)
{ }
@@ -132,7 +132,7 @@ bool L2CAPComm::connect() {
req.l2_psm = cpu_to_le(psm);
req.l2_bdaddr = device->getAddress();
req.l2_cid = cpu_to_le(cid);
- req.l2_bdaddr_type = pubaddr ? BDADDR_LE_PUBLIC : BDADDR_LE_RANDOM;
+ req.l2_bdaddr_type = device->getAddressType();
while( !interruptFlag ) {
// blocking