summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/BTAdapter.hpp28
-rw-r--r--api/direct_bt/BTManager.hpp5
-rw-r--r--api/direct_bt/BTTypes1.hpp21
-rw-r--r--api/direct_bt/L2CAPComm.hpp6
-rw-r--r--api/direct_bt/MgmtTypes.hpp1
-rw-r--r--examples/java/DBTScanner10.java4
-rw-r--r--examples/java/ScannerTinyB00.java2
-rw-r--r--examples/java/ScannerTinyB01.java2
-rw-r--r--examples/java/ScannerTinyB02.java2
-rw-r--r--java/jau/direct_bt/DBTAdapter.java36
-rw-r--r--java/jni/direct_bt/DBTManager.cxx6
-rw-r--r--java/org/direct_bt/BTAdapter.java25
-rw-r--r--java/org/direct_bt/BTFactory.java2
-rw-r--r--java/tinyb/dbus/DBusAdapter.java9
-rw-r--r--src/direct_bt/BTAdapter.cpp5
-rw-r--r--src/direct_bt/BTDevice.cpp2
-rw-r--r--src/direct_bt/BTManager.cpp9
-rw-r--r--src/direct_bt/L2CAPComm.cpp12
-rw-r--r--src/direct_bt/MgmtTypes.cpp4
-rw-r--r--src/direct_bt/SMPHandler.cpp2
20 files changed, 129 insertions, 54 deletions
diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp
index bad301d0..76c48b36 100644
--- a/api/direct_bt/BTAdapter.hpp
+++ b/api/direct_bt/BTAdapter.hpp
@@ -255,6 +255,11 @@ namespace direct_bt {
BTManager& mgmt;
AdapterInfo adapterInfo;
+ /**
+ * Either the adapter's initially reported public address or a random address setup via HCI before scanning / discovery.
+ */
+ BDAddressAndType visibleAddressAndType;
+
public:
/**
* Adapter's internal temporary device id.
@@ -463,7 +468,28 @@ namespace direct_bt {
*/
BTMode getBTMode() const noexcept { return adapterInfo.getCurrentBTMode(); }
- EUI48 const & getAddress() const noexcept { return adapterInfo.address; }
+ /**
+ * Returns the adapter's public BDAddressAndType.
+ * <p>
+ * The adapter's address as initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.
+ * </p>
+ * @since 2.2.8
+ * @see #getVisibleAddressAndType()
+ */
+ BDAddressAndType const & getAddressAndType() const noexcept { return adapterInfo.addressAndType; }
+
+ /**
+ * Returns the adapter's currently visible BDAddressAndType.
+ * <p>
+ * The adapter's address as initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.
+ * </p>
+ * <p>
+ * The adapter's visible BDAddressAndType might be set to BDAddressType::BDADDR_LE_RANDOM before scanning / discovery mode (TODO).
+ * </p>
+ * @since 2.2.8
+ * @see #getAddressAndType()
+ */
+ BDAddressAndType const & getVisibleAddressAndType() const noexcept { return visibleAddressAndType; }
/**
* Returns the system name.
diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp
index 428422c6..5cfd16e9 100644
--- a/api/direct_bt/BTManager.hpp
+++ b/api/direct_bt/BTManager.hpp
@@ -367,11 +367,6 @@ namespace direct_bt {
jau::darray<std::shared_ptr<BTAdapter>> getAdapters() { return *adapters.snapshot(); }
/**
- * Returns the DBTAdapter with the given address or nullptr if not found.
- */
- std::shared_ptr<BTAdapter> getAdapter(const EUI48 &mac) const noexcept;
-
- /**
* Returns the DBTAdapter with the given dev_id, or nullptr if not found.
*/
std::shared_ptr<BTAdapter> getAdapter(const uint16_t dev_id) const noexcept;
diff --git a/api/direct_bt/BTTypes1.hpp b/api/direct_bt/BTTypes1.hpp
index 9379b403..94da366a 100644
--- a/api/direct_bt/BTTypes1.hpp
+++ b/api/direct_bt/BTTypes1.hpp
@@ -186,7 +186,14 @@ namespace direct_bt {
public:
const uint16_t dev_id;
- const EUI48 address;
+ /**
+ * The adapter's address initially reported by the system is always its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.
+ * <p>
+ * Subsequent adapter setup using BDAddressType::BDADDR_LE_RANDOM must be handled within BTAdapter
+ * and is not reflected in AdapterInfo.
+ * </p>
+ */
+ const BDAddressAndType addressAndType;
const uint8_t version;
const uint16_t manufacturer;
@@ -212,11 +219,11 @@ namespace direct_bt {
void setShortName(const std::string v) noexcept { short_name = v; }
public:
- AdapterInfo(const uint16_t dev_id_, const EUI48 & address_,
+ AdapterInfo(const uint16_t dev_id_, const BDAddressAndType & addressAndType_,
const uint8_t version_, const uint16_t manufacturer_,
const AdapterSetting supported_setting_, const AdapterSetting current_setting_,
const uint32_t dev_class_, const std::string & name_, const std::string & short_name_) noexcept
- : dev_id(dev_id_), address(address_), version(version_),
+ : dev_id(dev_id_), addressAndType(addressAndType_), version(version_),
manufacturer(manufacturer_),
supported_setting(supported_setting_),
current_setting(current_setting_), dev_class(dev_class_),
@@ -224,7 +231,7 @@ namespace direct_bt {
{ }
AdapterInfo(const AdapterInfo &o) noexcept
- : dev_id(o.dev_id), address(o.address), version(o.version),
+ : dev_id(o.dev_id), addressAndType(o.addressAndType), version(o.version),
manufacturer(o.manufacturer),
supported_setting(o.supported_setting),
current_setting(o.current_setting.load()), dev_class(o.dev_class),
@@ -232,7 +239,7 @@ namespace direct_bt {
{ }
AdapterInfo& operator=(const AdapterInfo &o) {
if( this != &o ) {
- if( dev_id != o.dev_id || address != o.address ) {
+ if( dev_id != o.dev_id || addressAndType != o.addressAndType ) {
throw jau::IllegalArgumentException("Can't assign different device id's or address "+o.toString()+" -> "+toString(), E_FILE_LINE);
}
supported_setting = o.supported_setting;
@@ -244,7 +251,7 @@ namespace direct_bt {
return *this;
}
AdapterInfo(AdapterInfo&& o) noexcept
- : dev_id(std::move(o.dev_id)), address(std::move(o.address)), version(std::move(o.version)),
+ : dev_id(std::move(o.dev_id)), addressAndType(std::move(o.addressAndType)), version(std::move(o.version)),
manufacturer(std::move(o.manufacturer)),
supported_setting(std::move(o.supported_setting)),
current_setting(o.current_setting.load()), dev_class(std::move(o.dev_class)),
@@ -268,7 +275,7 @@ namespace direct_bt {
std::string getShortName() const noexcept { return short_name; }
std::string toString() const noexcept {
- return "AdapterInfo[id "+std::to_string(dev_id)+", address "+address.toString()+", version "+std::to_string(version)+
+ return "AdapterInfo[id "+std::to_string(dev_id)+", address "+addressAndType.toString()+", version "+std::to_string(version)+
", manuf "+std::to_string(manufacturer)+
", settings[sup "+to_string(supported_setting)+", cur "+to_string(current_setting)+
"], name '"+name+"', shortName '"+short_name+"']";
diff --git a/api/direct_bt/L2CAPComm.hpp b/api/direct_bt/L2CAPComm.hpp
index e9922531..40e9a85e 100644
--- a/api/direct_bt/L2CAPComm.hpp
+++ b/api/direct_bt/L2CAPComm.hpp
@@ -122,11 +122,11 @@ namespace direct_bt {
}
private:
- static int l2cap_open_dev(const EUI48 & adapterAddress, const L2CAP_PSM psm, const L2CAP_CID cid, const BDAddressType addrType);
+ static int l2cap_open_dev(const BDAddressAndType & adapterAddressAndType, const L2CAP_PSM psm, const L2CAP_CID cid);
static int l2cap_close_dev(int dd);
const L2CAPEnv & env;
- const EUI48 adapterAddress;
+ const BDAddressAndType adapterAddressAndType;
const L2CAP_PSM psm;
const L2CAP_CID cid;
@@ -146,7 +146,7 @@ namespace direct_bt {
/**
* Constructing a non connected L2CAP channel instance for the pre-defined PSM and CID.
*/
- L2CAPComm(const EUI48& adapterAddress, const L2CAP_PSM psm, const L2CAP_CID cid);
+ L2CAPComm(const BDAddressAndType& adapterAddressAndType, const L2CAP_PSM psm, const L2CAP_CID cid);
L2CAPComm(const L2CAPComm&) = delete;
void operator=(const L2CAPComm&) = delete;
diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp
index 90382539..0dd79ff6 100644
--- a/api/direct_bt/MgmtTypes.hpp
+++ b/api/direct_bt/MgmtTypes.hpp
@@ -2213,6 +2213,7 @@ namespace direct_bt {
: MgmtEvtCmdComplete(buffer, buffer_len, infoDataSize())
{ }
+ /** The adapter address reported is always the public address, i.e. BDAddressType::BDADDR_LE_PUBLIC. */
const EUI48& getAddress() const noexcept { return *reinterpret_cast<const EUI48 *>( pdu.get_ptr_nc(getDataOffset() + 0) ); }
uint8_t getVersion() const noexcept { return pdu.get_uint8_nc(getDataOffset()+6); }
uint16_t getManufacturer() const noexcept { return pdu.get_uint16_nc(getDataOffset()+7); }
diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java
index 4345815d..25ef619e 100644
--- a/examples/java/DBTScanner10.java
+++ b/examples/java/DBTScanner10.java
@@ -202,7 +202,7 @@ public class DBTScanner10 {
{
executeOffThread( () -> { startDiscovery(adapter, "powered-on"); },
- "DBT-StartDiscovery-"+adapter.getAddress(), true /* detach */);
+ "DBT-StartDiscovery-"+adapter.getAddressAndType(), true /* detach */);
}
}
@@ -343,7 +343,7 @@ public class DBTScanner10 {
}
if( 0 < RESET_ADAPTER_EACH_CONN && 0 == deviceReadyCount.get() % RESET_ADAPTER_EACH_CONN ) {
executeOffThread( () -> { resetAdapter(device.getAdapter(), 1); },
- "DBT-Reset-"+device.getAdapter().getAddress(), true /* detach */ );
+ "DBT-Reset-"+device.getAdapter().getAddressAndType(), true /* detach */ );
}
}
diff --git a/examples/java/ScannerTinyB00.java b/examples/java/ScannerTinyB00.java
index be34b609..6b10a2bb 100644
--- a/examples/java/ScannerTinyB00.java
+++ b/examples/java/ScannerTinyB00.java
@@ -129,7 +129,7 @@ public class ScannerTinyB00 {
}
adapter = adapters.get(dev_id);
if( !adapter.isPowered() ) {
- System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
+ System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddressAndType()+": "+adapter.toString());
System.exit(-1);
}
}
diff --git a/examples/java/ScannerTinyB01.java b/examples/java/ScannerTinyB01.java
index e5c229db..67fed321 100644
--- a/examples/java/ScannerTinyB01.java
+++ b/examples/java/ScannerTinyB01.java
@@ -153,7 +153,7 @@ public class ScannerTinyB01 {
}
adapter = adapters.get(dev_id);
if( !adapter.isPowered() ) {
- System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
+ System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddressAndType()+": "+adapter.toString());
System.exit(-1);
}
}
diff --git a/examples/java/ScannerTinyB02.java b/examples/java/ScannerTinyB02.java
index 2f1cf9de..67938901 100644
--- a/examples/java/ScannerTinyB02.java
+++ b/examples/java/ScannerTinyB02.java
@@ -129,7 +129,7 @@ public class ScannerTinyB02 {
}
adapter = adapters.get(dev_id);
if( !adapter.isPowered() ) {
- System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddress()+": "+adapter.toString());
+ System.err.println("Adapter not enabled: device "+adapter.getName()+", address "+adapter.getAddressAndType()+": "+adapter.toString());
System.exit(-1);
}
}
diff --git a/java/jau/direct_bt/DBTAdapter.java b/java/jau/direct_bt/DBTAdapter.java
index 8d8ae441..073f8e19 100644
--- a/java/jau/direct_bt/DBTAdapter.java
+++ b/java/jau/direct_bt/DBTAdapter.java
@@ -38,6 +38,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.direct_bt.AdapterSettings;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
+import org.direct_bt.BDAddressType;
import org.direct_bt.BTAdapter;
import org.direct_bt.BTDevice;
import org.direct_bt.BTException;
@@ -67,8 +68,15 @@ public class DBTAdapter extends DBTObject implements BTAdapter
private static int discoverTimeoutMS = 100;
private final int dev_id;
- private final EUI48 address;
+ /**
+ * The adapter's initially reported address by the system, which always reflects its public address, i.e. BDAddressType::BDADDR_LE_PUBLIC.
+ */
+ private final BDAddressAndType addressAndType;
private final String name;
+ /**
+ * Either the adapter's initially reported public address or a random address setup via HCI before scanning / discovery.
+ */
+ private final BDAddressAndType visibleAddressAndType;
private final Object discoveryLock = new Object();
private final Object discoveredDevicesLock = new Object();
@@ -88,12 +96,16 @@ public class DBTAdapter extends DBTObject implements BTAdapter
private final List<WeakReference<BTDevice>> discoveredDevices = new ArrayList<WeakReference<BTDevice>>();
- /* pp */ DBTAdapter(final long nativeInstance, final byte byteAddress[/*6*/], final String name, final int dev_id)
+ /* pp */ DBTAdapter(final long nativeInstance,
+ final byte byteAddress[/*6*/],
+ final byte byteAddressType,
+ final String name, final int dev_id)
{
- super( nativeInstance, compHash( dev_id, java.util.Arrays.hashCode(byteAddress) ) );
+ super(nativeInstance, compHash(java.util.Arrays.hashCode(byteAddress), 31+byteAddressType));
this.dev_id = dev_id;
- this.address = new EUI48(byteAddress);
+ this.addressAndType = new BDAddressAndType(new EUI48(byteAddress), BDAddressType.get(byteAddressType));
this.name = name;
+ this.visibleAddressAndType = addressAndType;
addStatusListener(this.statusListener);
}
@@ -148,14 +160,20 @@ public class DBTAdapter extends DBTObject implements BTAdapter
return false;
}
final DBTAdapter other = (DBTAdapter)obj;
- return dev_id == other.dev_id && address.equals(other.address);
+ return dev_id == other.dev_id && addressAndType.equals(other.addressAndType);
}
@Override
- public EUI48 getAddress() { return address; }
+ public BDAddressAndType getAddressAndType() { return addressAndType; }
+
+ @Override
+ public BDAddressAndType getVisibleAddressAndType() { return visibleAddressAndType; }
+
+ @Override
+ public EUI48 getAddress() { return addressAndType.address; }
@Override
- public String getAddressString() { return address.toString(); }
+ public String getAddressString() { return addressAndType.address.toString(); }
@Override
public String getName() { return name; }
@@ -314,7 +332,7 @@ public class DBTAdapter extends DBTObject implements BTAdapter
@Override
public String toString() {
if( !isValid() ) {
- return "Adapter" + "\u271D" + "["+address+", '"+name+"', id "+dev_id+"]";
+ return "Adapter" + "\u271D" + "["+addressAndType+", '"+name+"', id "+dev_id+"]";
}
return toStringImpl();
}
@@ -678,7 +696,7 @@ public class DBTAdapter extends DBTObject implements BTAdapter
@Override
public String toString() {
- return "AdapterStatusListener[adapter "+address.toString()+"]";
+ return "AdapterStatusListener[adapter "+addressAndType.toString()+"]";
}
};
diff --git a/java/jni/direct_bt/DBTManager.cxx b/java/jni/direct_bt/DBTManager.cxx
index 24665b97..b35fe37a 100644
--- a/java/jni/direct_bt/DBTManager.cxx
+++ b/java/jni/direct_bt/DBTManager.cxx
@@ -143,16 +143,16 @@ void Java_jau_direct_1bt_DBTManager_deleteImpl(JNIEnv *env, jobject obj, jlong n
}
}
-static const std::string _adapterClazzCtorArgs("(J[BLjava/lang/String;I)V");
+static const std::string _adapterClazzCtorArgs("(J[BBLjava/lang/String;I)V");
static jobject _createJavaAdapter(JNIEnv *env_, jclass clazz, jmethodID clazz_ctor, BTAdapter* adapter) {
// prepare adapter ctor
- const EUI48 addr = adapter->getAddress();
+ const EUI48 addr = adapter->getAddressAndType().address;
jbyteArray jaddr = env_->NewByteArray(sizeof(addr));
env_->SetByteArrayRegion(jaddr, 0, sizeof(addr), (const jbyte*)(addr.b));
jau::java_exception_check_and_throw(env_, E_FILE_LINE);
const jstring name = from_string_to_jstring(env_, adapter->getName());
java_exception_check_and_throw(env_, E_FILE_LINE);
- jobject jAdapter = env_->NewObject(clazz, clazz_ctor, (jlong)adapter, jaddr, name, adapter->dev_id);
+ jobject jAdapter = env_->NewObject(clazz, clazz_ctor, (jlong)adapter, jaddr, adapter->getAddressAndType().type, name, adapter->dev_id);
java_exception_check_and_throw(env_, E_FILE_LINE);
JNIGlobalRef::check(jAdapter, E_FILE_LINE);
std::shared_ptr<JavaAnon> jAdapterRef = adapter->getJavaObject(); // GlobalRef
diff --git a/java/org/direct_bt/BTAdapter.java b/java/org/direct_bt/BTAdapter.java
index dca8e3e7..4cc3bf28 100644
--- a/java/org/direct_bt/BTAdapter.java
+++ b/java/org/direct_bt/BTAdapter.java
@@ -217,11 +217,36 @@ public interface BTAdapter extends BTObject
/* D-Bus property accessors: */
/**
+ * Returns the adapter's public BDAddressAndType.
+ * <p>
+ * The adapter's address as initially reported by the system is always its public address, i.e. {@link BDAddressType#BDADDR_LE_PUBLIC}.
+ * </p>
+ * @since 2.2.8
+ * @see #getVisibleAddressAndType()
+ */
+ BDAddressAndType getAddressAndType();
+
+ /**
+ * Returns the adapter's currently visible BDAddressAndType.
+ * <p>
+ * The adapter's address as initially reported by the system is always its public address, i.e. {@link BDAddressType#BDADDR_LE_PUBLIC}.
+ * </p>
+ * <p>
+ * The adapter's visible BDAddressAndType might be set to {@link BDAddressType#BDADDR_LE_RANDOM} before scanning / discovery mode (TODO).
+ * </p>
+ * @since 2.2.8
+ * @see #getAddressAndType()
+ */
+ BDAddressAndType getVisibleAddressAndType();
+
+ /**
* Returns the hardware address of this adapter.
* @return The hardware address of this adapter.
* @implNote Changed to EUI48 since version 2.2.0
* @since 2.2.0
+ * @deprecated Use {@link #getAddressAndType()} and {@link #getVisibleAddressAndType()}
*/
+ @Deprecated
EUI48 getAddress();
/**
diff --git a/java/org/direct_bt/BTFactory.java b/java/org/direct_bt/BTFactory.java
index 44fc11b9..018744d3 100644
--- a/java/org/direct_bt/BTFactory.java
+++ b/java/org/direct_bt/BTFactory.java
@@ -598,7 +598,7 @@ public class BTFactory {
System.err.println("BTAdapter["+i+"]: "+iter.next().toString()); // has full toString()
} else {
final BTAdapter a = iter.next();
- System.err.println("BTAdapter["+i+"]: dev_id "+a.getDevID()+", address "+a.getAddress()+", name "+a.getName());
+ System.err.println("BTAdapter["+i+"]: dev_id "+a.getDevID()+", address "+a.getAddressAndType()+", name "+a.getName());
}
}
} catch (BTException | NoSuchMethodException | SecurityException
diff --git a/java/tinyb/dbus/DBusAdapter.java b/java/tinyb/dbus/DBusAdapter.java
index 41a69d07..e713982e 100644
--- a/java/tinyb/dbus/DBusAdapter.java
+++ b/java/tinyb/dbus/DBusAdapter.java
@@ -36,6 +36,7 @@ import java.util.UUID;
import org.direct_bt.AdapterStatusListener;
import org.direct_bt.BDAddressAndType;
+import org.direct_bt.BDAddressType;
import org.direct_bt.BTAdapter;
import org.direct_bt.BTDevice;
import org.direct_bt.BTException;
@@ -136,10 +137,16 @@ public class DBusAdapter extends DBusObject implements BTAdapter
/* D-Bus property accessors: */
@Override
+ public native String getAddressString();
+
+ @Override
public EUI48 getAddress() { return new EUI48(getAddressString()); }
@Override
- public native String getAddressString();
+ public BDAddressAndType getAddressAndType() { return new BDAddressAndType(getAddress(), BDAddressType.BDADDR_LE_PUBLIC); }
+
+ @Override
+ public BDAddressAndType getVisibleAddressAndType() { return getAddressAndType(); }
@Override
public native String getName();
diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp
index 0c5475d0..f1ad21eb 100644
--- a/src/direct_bt/BTAdapter.cpp
+++ b/src/direct_bt/BTAdapter.cpp
@@ -207,6 +207,7 @@ BTAdapter::BTAdapter(const BTAdapter::ctor_cookie& cc, BTManager& mgmt_, const A
debug_lock(jau::environment::getBooleanProperty("direct_bt.debug.adapter.lock", false)),
mgmt( mgmt_ ),
adapterInfo( adapterInfo_ ),
+ visibleAddressAndType( adapterInfo_.addressAndType ),
dev_id( adapterInfo.dev_id ),
hci( dev_id )
{
@@ -928,7 +929,9 @@ void BTAdapter::removeDevice(BTDevice & device) noexcept {
}
std::string BTAdapter::toString(bool includeDiscoveredDevices) const noexcept {
- std::string out("Adapter[BTMode "+to_string(btMode)+", "+adapterInfo.address.toString()+", '"+getName()+"', id "+std::to_string(dev_id)+
+ std::string random_address_info = adapterInfo.addressAndType != visibleAddressAndType ? " ("+visibleAddressAndType.toString()+")" : "";
+ std::string out("Adapter[BTMode "+to_string(btMode)+", "+adapterInfo.addressAndType.toString()+random_address_info+
+ ", '"+getName()+"', id "+std::to_string(dev_id)+
", curSettings"+to_string(adapterInfo.getCurrentSettingMask())+
", scanType[native "+to_string(hci.getCurrentScanType())+", meta "+to_string(currentMetaScanType)+"]"
", valid "+std::to_string(isValid())+", open[mgmt, "+std::to_string(mgmt.isOpen())+", hci "+std::to_string(hci.isOpen())+
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 74e518bb..236a6a85 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -46,7 +46,7 @@ using namespace direct_bt;
BTDevice::BTDevice(const ctor_cookie& cc, BTAdapter & a, EInfoReport const & r)
: adapter(a),
- l2cap_att(adapter.getAddress(), L2CAP_PSM::UNDEFINED, L2CAP_CID::ATT),
+ l2cap_att(adapter.getAddressAndType(), L2CAP_PSM::UNDEFINED, L2CAP_CID::ATT),
ts_creation(r.getTimestamp()),
addressAndType{r.getAddress(), r.getAddressType()}
{
diff --git a/src/direct_bt/BTManager.cpp b/src/direct_bt/BTManager.cpp
index 2338b0fb..3f26e379 100644
--- a/src/direct_bt/BTManager.cpp
+++ b/src/direct_bt/BTManager.cpp
@@ -621,15 +621,6 @@ std::shared_ptr<BTAdapter> BTManager::getDefaultAdapter() const noexcept {
return nullptr;
}
-std::shared_ptr<BTAdapter> BTManager::getAdapter(const EUI48 &mac) const noexcept {
- typename adapters_t::const_iterator it = adapters.cbegin();
- for (; !it.is_end(); ++it) {
- if ( (*it)->adapterInfo.address == mac ) {
- return *it;
- }
- }
- return nullptr;
-}
std::shared_ptr<BTAdapter> BTManager::getAdapter(const uint16_t dev_id) const noexcept {
typename adapters_t::const_iterator it = adapters.cbegin();
for (; !it.is_end(); ++it) {
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index e4b1ca1f..5d1e15d6 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -61,7 +61,7 @@ L2CAPEnv::L2CAPEnv() noexcept
{
}
-int L2CAPComm::l2cap_open_dev(const EUI48 & adapterAddress, const L2CAP_PSM psm, const L2CAP_CID cid, const BDAddressType addrType) {
+int L2CAPComm::l2cap_open_dev(const BDAddressAndType & adapterAddressAndType, const L2CAP_PSM psm, const L2CAP_CID cid) {
sockaddr_l2 a;
int fd, err;
@@ -79,9 +79,9 @@ int L2CAPComm::l2cap_open_dev(const EUI48 & adapterAddress, const L2CAP_PSM psm,
bzero((void *)&a, sizeof(a));
a.l2_family=AF_BLUETOOTH;
a.l2_psm = jau::cpu_to_le(direct_bt::number(psm));
- a.l2_bdaddr = adapterAddress;
+ a.l2_bdaddr = adapterAddressAndType.address;
a.l2_cid = jau::cpu_to_le(direct_bt::number(cid));
- a.l2_bdaddr_type = ::number(addrType);
+ a.l2_bdaddr_type = ::number(adapterAddressAndType.type);
if ( ::bind(fd, (struct sockaddr *) &a, sizeof(a)) < 0 ) {
ERR_PRINT("L2CAPComm::l2cap_open_dev: bind failed");
goto failed;
@@ -106,9 +106,9 @@ int L2CAPComm::l2cap_close_dev(int dd)
// *************************************************
// *************************************************
-L2CAPComm::L2CAPComm(const EUI48& adapterAddress_, const L2CAP_PSM psm_, const L2CAP_CID cid_)
+L2CAPComm::L2CAPComm(const BDAddressAndType& adapterAddressAndType_, const L2CAP_PSM psm_, const L2CAP_CID cid_)
: env(L2CAPEnv::get()),
- adapterAddress(adapterAddress_),
+ adapterAddressAndType(adapterAddressAndType_),
psm(psm_), cid(cid_),
deviceAddressAndType(BDAddressAndType::ANY_BREDR_DEVICE),
socket_descriptor(-1),
@@ -164,7 +164,7 @@ bool L2CAPComm::open(const BTDevice& device, const BTSecurityLevel sec_level) {
getStateString().c_str(), socket_descriptor.load(), deviceAddressAndType.toString().c_str(),
to_string(psm).c_str(), to_string(cid).c_str());
- socket_descriptor = l2cap_open_dev(adapterAddress, psm, cid, BDAddressType::BDADDR_LE_PUBLIC);
+ socket_descriptor = l2cap_open_dev(adapterAddressAndType, psm, cid);
if( 0 > socket_descriptor ) {
goto failure; // open failed
diff --git a/src/direct_bt/MgmtTypes.cpp b/src/direct_bt/MgmtTypes.cpp
index 7b280aa6..b9b99dcc 100644
--- a/src/direct_bt/MgmtTypes.cpp
+++ b/src/direct_bt/MgmtTypes.cpp
@@ -485,7 +485,9 @@ std::shared_ptr<NameAndShortName> MgmtEvtLocalNameChanged::toNameAndShortName()
std::unique_ptr<AdapterInfo> MgmtEvtAdapterInfo::toAdapterInfo() const noexcept {
return std::make_unique<AdapterInfo>(
- getDevID(), getAddress(), getVersion(),
+ getDevID(),
+ BDAddressAndType(getAddress(), BDAddressType::BDADDR_LE_PUBLIC),
+ getVersion(),
getManufacturer(), getSupportedSetting(),
getCurrentSetting(), getDevClass(),
getName(), getShortName());
diff --git a/src/direct_bt/SMPHandler.cpp b/src/direct_bt/SMPHandler.cpp
index f61a8ed1..ca7585de 100644
--- a/src/direct_bt/SMPHandler.cpp
+++ b/src/direct_bt/SMPHandler.cpp
@@ -158,7 +158,7 @@ void SMPHandler::l2capReaderThreadImpl() {
SMPHandler::SMPHandler(const std::shared_ptr<BTDevice> &device) noexcept
: env(SMPEnv::get()),
wbr_device(device), deviceString(device->getAddressAndType().toString()), rbuffer(number(Defaults::SMP_MTU_BUFFER_SZ)),
- l2cap(device->getAdapter().getAddress(), L2CAP_PSM::UNDEFINED, L2CAP_CID::SMP),
+ l2cap(device->getAdapter().getAddressAndType(), L2CAP_PSM::UNDEFINED, L2CAP_CID::SMP),
is_connected(l2cap.open(*device)), has_ioerror(false),
smpPDURing(nullptr, env.SMPPDU_RING_CAPACITY), l2capReaderShallStop(false),
l2capReaderThreadId(0), l2capReaderRunning(false),