summaryrefslogtreecommitdiffstats
path: root/src/direct_bt
diff options
context:
space:
mode:
Diffstat (limited to 'src/direct_bt')
-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
6 files changed, 15 insertions, 19 deletions
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),