diff options
author | Sven Gothel <[email protected]> | 2022-05-05 22:52:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-05-05 22:52:11 +0200 |
commit | 53159c09d953475e1816f1c0c5be6c3cdb76b545 (patch) | |
tree | 849d03a5189280bf87dbc902f39fc28b6ecb7931 /src | |
parent | d31fb734b1400211e93893162f0ef7ec73731690 (diff) |
Adopt to JavaUplink::checkValidInstance(): BTObject::{isValid()->isValidInstance()} for clarity; BTAdapter adds `adapter_operational` flag for its own isValid()
Diffstat (limited to 'src')
-rw-r--r-- | src/direct_bt/BTAdapter.cpp | 12 | ||||
-rw-r--r-- | src/direct_bt/BTDevice.cpp | 10 |
2 files changed, 11 insertions, 11 deletions
diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp index 5c4f3fd6..71e1b002 100644 --- a/src/direct_bt/BTAdapter.cpp +++ b/src/direct_bt/BTAdapter.cpp @@ -399,7 +399,7 @@ BTAdapter::BTAdapter(const BTAdapter::ctor_cookie& cc, BTManager& mgmt_, const A { (void)cc; - valid = initialSetup(); + adapter_operational = initialSetup(); if( isValid() ) { const bool r = smp_watchdog.start(SMP_NEXT_EVENT_TIMEOUT_MS, jau::bindMemberFunc(this, &BTAdapter::smp_timeoutfunc)); DBG_PRINT("BTAdapter::ctor: dev_id %d: smp_watchdog.smp_timeoutfunc started %d", dev_id, r); @@ -472,7 +472,7 @@ void BTAdapter::close() noexcept { key_list.clear(); key_path.clear(); } - valid = false; + adapter_operational = false; DBG_PRINT("BTAdapter::close: XXX"); } @@ -527,7 +527,7 @@ void BTAdapter::printDeviceList(const std::string& prefix, const BTAdapter::devi for (auto it = list.begin(); it != list.end(); ++idx, ++it) { if( nullptr != (*it) ) { jau::PLAIN_PRINT(true, " - %d / %zu: null", (idx+1), sz); - } else if( (*it)->isValid() ) { + } else if( (*it)->isValidInstance() ) { jau::PLAIN_PRINT(true, " - %d / %zu: invalid", (idx+1), sz); } else { jau::PLAIN_PRINT(true, " - %d / %zu: %s, name '%s'", (idx+1), sz, @@ -545,7 +545,7 @@ void BTAdapter::printWeakDeviceList(const std::string& prefix, BTAdapter::weak_d BTDeviceRef e = w.lock(); if( nullptr == e ) { jau::PLAIN_PRINT(true, " - %d / %zu: null", (idx+1), sz); - } else if( !e->isValid() ) { + } else if( !e->isValidInstance() ) { jau::PLAIN_PRINT(true, " - %d / %zu: invalid", (idx+1), sz); } else { jau::PLAIN_PRINT(true, " - %d / %zu: %s, name '%s'", (idx+1), sz, @@ -1861,7 +1861,7 @@ jau::fraction_i64 BTAdapter::smp_timeoutfunc(jau::simple_timer& timer) { { const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor jau::for_each_fidelity(connectedDevices, [&](BTDeviceRef& device) { - if( device->isValid() && device->getConnected() && + if( device->isValidInstance() && device->getConnected() && BTSecurityLevel::NONE < device->getConnSecurityLevel() && SMPPairingState::KEY_DISTRIBUTION == device->pairing_data.state ) // isSMPPairingActive( device->pairing_data.state ) && @@ -2634,7 +2634,7 @@ void BTAdapter::sendDeviceReady(BTDeviceRef device, uint64_t timestamp) noexcept jau::for_each_fidelity(statusListenerList, [&](impl::StatusListenerPair &p) { try { // Only issue if valid && received connected confirmation (HCI) && not have called disconnect yet. - if( device->isValid() && device->getConnected() && device->allowDisconnect ) { + if( device->isValidInstance() && device->getConnected() && device->allowDisconnect ) { if( p.listener->matchDevice(*device) ) { p.listener->deviceReady(device, timestamp); } diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp index e7d7a92c..efbabb4f 100644 --- a/src/direct_bt/BTDevice.cpp +++ b/src/direct_bt/BTDevice.cpp @@ -1430,7 +1430,7 @@ SMPKeyType BTDevice::getAvailableSMPKeys(const bool responder) const noexcept { bool BTDevice::setSMPKeyBin(const SMPKeyBin& bin) noexcept { const std::unique_lock<std::recursive_mutex> lock_pairing(mtx_pairing); // RAII-style acquire and relinquish via destructor - if( !isValid() ) { + if( !isValidInstance() ) { ERR_PRINT("Device invalid: %p", jau::to_hexstring((void*)this).c_str()); return false; } @@ -1643,7 +1643,7 @@ SMPIOCapability BTDevice::getConnIOCapability() const noexcept { } bool BTDevice::setConnSecurity(const BTSecurityLevel sec_level, const SMPIOCapability io_cap) noexcept { - if( !isValid() ) { + if( !isValidInstance() ) { ERR_PRINT("Device invalid: %p", jau::to_hexstring((void*)this).c_str()); return false; } @@ -1685,7 +1685,7 @@ bool BTDevice::setConnSecurity(const BTSecurityLevel sec_level, const SMPIOCapab } bool BTDevice::setConnSecurityAuto(const SMPIOCapability iocap_auto) noexcept { - if( !isValid() ) { + if( !isValidInstance() ) { ERR_PRINT("Device invalid: %p", jau::to_hexstring((void*)this).c_str()); return false; } @@ -2040,7 +2040,7 @@ BTGattCharRef BTDevice::findGattChar(const jau::uuid_t& char_uuid) noexcept { } bool BTDevice::sendNotification(const uint16_t char_value_handle, const jau::TROOctets & value) noexcept { - if( !isValid() ) { + if( !isValidInstance() ) { ERR_PRINT("Device invalid: %p", jau::to_hexstring((void*)this).c_str()); return false; } @@ -2053,7 +2053,7 @@ bool BTDevice::sendNotification(const uint16_t char_value_handle, const jau::TRO } bool BTDevice::sendIndication(const uint16_t char_value_handle, const jau::TROOctets & value) noexcept { - if( !isValid() ) { + if( !isValidInstance() ) { ERR_PRINT("Device invalid: %p", jau::to_hexstring((void*)this).c_str()); return false; } |