aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-04-22 01:51:18 +0200
committerSven Gothel <[email protected]>2022-04-22 01:51:18 +0200
commitae3d882baf5634443481fed9555ca0f3bb472fa3 (patch)
treee1eeb3e9edd17d4ed39bb8db05bcf3e5b139da1e
parent454034a4a7cf066cd69609cba71578a17c142a3e (diff)
Remove explicit atomic::load() calls written out where redundant (type operator)
-rw-r--r--api/direct_bt/BTDevice.hpp2
-rw-r--r--src/direct_bt/BTAdapter.cpp28
-rw-r--r--src/direct_bt/BTDevice.cpp10
-rw-r--r--src/direct_bt/BTGattServerHandler.cpp2
-rw-r--r--src/direct_bt/L2CAPComm.cpp4
5 files changed, 23 insertions, 23 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp
index 5a379cb9..7534e716 100644
--- a/api/direct_bt/BTDevice.hpp
+++ b/api/direct_bt/BTDevice.hpp
@@ -412,7 +412,7 @@ namespace direct_bt {
/**
* Return true if the device has been successfully connected, otherwise false.
*/
- bool getConnected() noexcept { return isConnected.load(); }
+ bool getConnected() noexcept { return isConnected; }
/**
* Establish a HCI BDADDR_LE_PUBLIC or BDADDR_LE_RANDOM connection to this device.
diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp
index 250b290d..44b64fb7 100644
--- a/src/direct_bt/BTAdapter.cpp
+++ b/src/direct_bt/BTAdapter.cpp
@@ -1028,7 +1028,7 @@ void BTAdapter::checkDiscoveryState() noexcept {
// Check LE scan state
if( DiscoveryPolicy::AUTO_OFF == discovery_policy ) {
if( hasScanType(currentMetaScanType, ScanType::LE) != hasScanType(currentNativeScanType, ScanType::LE) ) {
- std::string msg("Invalid DiscoveryState: policy "+to_string(discovery_policy.load())+
+ std::string msg("Invalid DiscoveryState: policy "+to_string(discovery_policy)+
", currentScanType*[native "+
to_string(currentNativeScanType)+" != meta "+
to_string(currentMetaScanType)+"], "+toString());
@@ -1037,7 +1037,7 @@ void BTAdapter::checkDiscoveryState() noexcept {
}
} else {
if( !hasScanType(currentMetaScanType, ScanType::LE) && hasScanType(currentNativeScanType, ScanType::LE) ) {
- std::string msg("Invalid DiscoveryState: policy "+to_string(discovery_policy.load())+
+ std::string msg("Invalid DiscoveryState: policy "+to_string(discovery_policy)+
", currentScanType*[native "+
to_string(currentNativeScanType)+", meta "+
to_string(currentMetaScanType)+"], "+toString());
@@ -1082,11 +1082,11 @@ HCIStatusCode BTAdapter::startDiscovery(const DiscoveryPolicy policy, const bool
btRole = BTRole::Master;
if( discovery_policy == policy ) {
DBG_PRINT("BTAdapter::startDiscovery: Already discovering, unchanged policy %s -> %s, currentScanType[native %s, meta %s] ...\n- %s",
- to_string(discovery_policy.load()).c_str(), to_string(policy).c_str(),
+ to_string(discovery_policy).c_str(), to_string(policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str(), toString(true).c_str());
} else {
DBG_PRINT("BTAdapter::startDiscovery: Already discovering, changed policy %s -> %s, currentScanType[native %s, meta %s] ...\n- %s",
- to_string(discovery_policy.load()).c_str(), to_string(policy).c_str(),
+ to_string(discovery_policy).c_str(), to_string(policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str(), toString(true).c_str());
discovery_policy = policy;
}
@@ -1096,7 +1096,7 @@ HCIStatusCode BTAdapter::startDiscovery(const DiscoveryPolicy policy, const bool
if( _print_device_lists || jau::environment::get().verbose ) {
jau::PLAIN_PRINT(true, "BTAdapter::startDiscovery: Start: policy %s -> %s, currentScanType[native %s, meta %s] ...\n- %s",
- to_string(discovery_policy.load()).c_str(), to_string(policy).c_str(),
+ to_string(discovery_policy).c_str(), to_string(policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str(), toString().c_str());
}
@@ -1112,7 +1112,7 @@ HCIStatusCode BTAdapter::startDiscovery(const DiscoveryPolicy policy, const bool
if( _print_device_lists || jau::environment::get().verbose ) {
jau::PLAIN_PRINT(true, "BTAdapter::startDiscovery: End: Result %s, policy %s -> %s, currentScanType[native %s, meta %s] ...\n- %s",
to_string(status).c_str(),
- to_string(discovery_policy.load()).c_str(), to_string(policy).c_str(),
+ to_string(discovery_policy).c_str(), to_string(policy).c_str(),
to_string(hci.getCurrentScanType()).c_str(), to_string(currentMetaScanType).c_str(), toString().c_str());
printDeviceLists();
}
@@ -1142,7 +1142,7 @@ void BTAdapter::startDiscoveryBackground() noexcept {
// if le_enable_scan(..) is successful, it will issue 'mgmtEvDeviceDiscoveringHCI(..)' immediately, which updates currentMetaScanType.
DBG_PRINT("BTAdapter::startDiscoveryBackground[%u/%u]: Policy %s, currentScanType[native %s, meta %s] ... %s",
trial_count+1, MAX_BACKGROUND_DISCOVERY_RETRY,
- to_string(discovery_policy.load()).c_str(),
+ to_string(discovery_policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str(), toString().c_str());
const HCIStatusCode status = hci.le_enable_scan(true /* enable */, scan_filter_dup);
if( HCIStatusCode::SUCCESS != status ) {
@@ -1199,7 +1199,7 @@ HCIStatusCode BTAdapter::stopDiscoveryImpl(const bool forceDiscoveringEvent, con
DiscoveryPolicy::AUTO_OFF != discovery_policy; // true
DBG_PRINT("BTAdapter::stopDiscovery: Start: policy %s, currentScanType[native %s, meta %s], le_scan_temp_disabled %d, forceDiscEvent %d ...",
- to_string(discovery_policy.load()).c_str(),
+ to_string(discovery_policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str(),
le_scan_temp_disabled, forceDiscoveringEvent);
@@ -1209,7 +1209,7 @@ HCIStatusCode BTAdapter::stopDiscoveryImpl(const bool forceDiscoveringEvent, con
if( !hasScanType(currentMetaScanType, ScanType::LE) ) {
DBG_PRINT("BTAdapter::stopDiscovery: Already disabled, policy %s, currentScanType[native %s, meta %s] ...",
- to_string(discovery_policy.load()).c_str(),
+ to_string(discovery_policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(currentMetaScanType).c_str());
checkDiscoveryState();
return HCIStatusCode::SUCCESS;
@@ -1250,7 +1250,7 @@ exit:
}
if( _print_device_lists || jau::environment::get().verbose ) {
jau::PLAIN_PRINT(true, "BTAdapter::stopDiscovery: End: Result %s, policy %s, currentScanType[native %s, meta %s], le_scan_temp_disabled %d ...\n- %s",
- to_string(status).c_str(), to_string(discovery_policy.load()).c_str(),
+ to_string(status).c_str(), to_string(discovery_policy).c_str(),
to_string(hci.getCurrentScanType()).c_str(), to_string(currentMetaScanType).c_str(), le_scan_temp_disabled,
toString().c_str());
printDeviceLists();
@@ -1677,14 +1677,14 @@ bool BTAdapter::mgmtEvDeviceDiscoveringAny(const ScanType eventScanType, const b
// update HCIHandler's currentNativeScanType from other source
const ScanType nextNativeScanType = changeScanType(currentNativeScanType, eventScanType, eventEnabled);
DBG_PRINT("BTAdapter:%s:DeviceDiscovering: dev_id %d, policy %s: scanType[native %s -> %s, meta %s -> %s])",
- srctkn.c_str(), dev_id, to_string(discovery_policy.load()).c_str(),
+ srctkn.c_str(), dev_id, to_string(discovery_policy).c_str(),
to_string(currentNativeScanType).c_str(), to_string(nextNativeScanType).c_str(),
to_string(currentMetaScanType).c_str(), to_string(nextMetaScanType).c_str());
currentNativeScanType = nextNativeScanType;
hci.setCurrentScanType(currentNativeScanType);
} else {
DBG_PRINT("BTAdapter:%s:DeviceDiscovering: dev_id %d, policy %d: scanType[native %s, meta %s -> %s])",
- srctkn.c_str(), dev_id, to_string(discovery_policy.load()).c_str(),
+ srctkn.c_str(), dev_id, to_string(discovery_policy).c_str(),
to_string(currentNativeScanType).c_str(),
to_string(currentMetaScanType).c_str(), to_string(nextMetaScanType).c_str());
}
@@ -1868,7 +1868,7 @@ jau::nsize_t BTAdapter::smp_timeoutfunc(jau::simple_timer& timer) {
// !isSMPPairingUserInteraction( device->pairing_data.state ) )
{
// actively within SMP negotiations, excluding user interaction
- const uint32_t smp_events = device->smp_events.load();
+ const uint32_t smp_events = device->smp_events;
DBG_PRINT("BTAdapter::smp_timeoutfunc(dev_id %d): SMP Timeout: Check %u -> %s", dev_id, smp_events, device->toString().c_str());
if( 0 == smp_events ) {
failed_devices.push_back(device);
@@ -1876,7 +1876,7 @@ jau::nsize_t BTAdapter::smp_timeoutfunc(jau::simple_timer& timer) {
device->smp_events = 0;
}
} else {
- const uint32_t smp_events = device->smp_events.load();
+ const uint32_t smp_events = device->smp_events;
DBG_PRINT("BTAdapter::smp_timeoutfunc(dev_id %d): SMP Timeout: Ignore %u -> %s", dev_id, smp_events, device->toString().c_str());
}
});
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 6ccc2fe6..67569771 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -2158,7 +2158,7 @@ HCIStatusCode BTDevice::getConnectedLE_PHY(LE_PHYs& resTx, LE_PHYs& resRx) noexc
}
HCIHandler &hci = adapter.getHCI();
- HCIStatusCode res = hci.le_read_phy(hciConnHandle.load(), addressAndType, resTx, resRx);
+ HCIStatusCode res = hci.le_read_phy(hciConnHandle, addressAndType, resTx, resRx);
if( HCIStatusCode::SUCCESS == res ) {
le_phy_tx = resTx;
le_phy_rx = resRx;
@@ -2182,7 +2182,7 @@ HCIStatusCode BTDevice::setConnectedLE_PHY(const LE_PHYs Tx, const LE_PHYs Rx) n
}
HCIHandler &hci = adapter.getHCI();
- return hci.le_set_phy(hciConnHandle.load(), addressAndType, Tx, Rx);
+ return hci.le_set_phy(hciConnHandle, addressAndType, Tx, Rx);
}
void BTDevice::notifyDisconnected() noexcept {
@@ -2248,7 +2248,7 @@ HCIStatusCode BTDevice::disconnect(const HCIStatusCode reason) noexcept {
goto exit;
}
- res = hci.disconnect(hciConnHandle.load(), addressAndType, reason);
+ res = hci.disconnect(hciConnHandle, addressAndType, reason);
if( HCIStatusCode::SUCCESS != res ) {
ERR_PRINT("status %s, handle 0x%X, isConnected %d/%d: errno %d %s on %s",
to_string(res).c_str(), hciConnHandle.load(),
@@ -2264,9 +2264,9 @@ exit:
// send the DISCONN_COMPLETE event directly.
// SEND_EVENT: Perform off-thread to avoid potential deadlock w/ application callbacks (similar when sent from HCIHandler's reader-thread)
std::thread bg(&BTDevice::sendMgmtEvDeviceDisconnected, this, // @suppress("Invalid arguments")
- std::make_unique<MgmtEvtDeviceDisconnected>(adapter.dev_id, addressAndType, reason, hciConnHandle.load()) );
+ std::make_unique<MgmtEvtDeviceDisconnected>(adapter.dev_id, addressAndType, reason, hciConnHandle) );
bg.detach();
- // adapter.mgmtEvDeviceDisconnectedHCI( std::unique_ptr<MgmtEvent>( new MgmtEvtDeviceDisconnected(adapter.dev_id, address, addressType, reason, hciConnHandle.load()) ) );
+ // adapter.mgmtEvDeviceDisconnectedHCI( std::unique_ptr<MgmtEvent>( new MgmtEvtDeviceDisconnected(adapter.dev_id, address, addressType, reason, hciConnHandle) ) );
}
WORDY_PRINT("BTDevice::disconnect: End: status %s, handle 0x%X, isConnected %d/%d on %s",
to_string(res).c_str(),
diff --git a/src/direct_bt/BTGattServerHandler.cpp b/src/direct_bt/BTGattServerHandler.cpp
index b90eb97e..1cbebd90 100644
--- a/src/direct_bt/BTGattServerHandler.cpp
+++ b/src/direct_bt/BTGattServerHandler.cpp
@@ -731,7 +731,7 @@ class DBGattServerHandler : public BTGattHandler::GattServerHandler {
}
- // const jau::nsize_t rspMaxSize = std::min<jau::nsize_t>(255, getUsedMTU().load()-2);
+ // const jau::nsize_t rspMaxSize = std::min<jau::nsize_t>(255, getUsedMTU()-2);
AttFindByTypeValueRsp rsp(gh.getUsedMTU()); // maximum size
jau::nsize_t rspSize = 0;
jau::nsize_t rspCount = 0;
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index a2c47b51..7819a093 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -686,7 +686,7 @@ errout:
}
std::string L2CAPClient::toString() const noexcept {
- return "L2CAPClient[dev_id "+std::to_string(adev_id)+", dd "+std::to_string(socket_.load())+
+ return "L2CAPClient[dev_id "+std::to_string(adev_id)+", dd "+std::to_string(socket_)+
", psm "+to_string(psm)+
", cid "+to_string(cid)+
", local "+localAddressAndType.toString()+
@@ -860,7 +860,7 @@ std::unique_ptr<L2CAPClient> L2CAPServer::accept() noexcept {
}
std::string L2CAPServer::toString() const noexcept {
- return "L2CAPServer[dev_id "+std::to_string(adev_id)+", dd "+std::to_string(socket_.load())+
+ return "L2CAPServer[dev_id "+std::to_string(adev_id)+", dd "+std::to_string(socket_)+
", psm "+to_string(psm)+
", cid "+to_string(cid)+
", local "+localAddressAndType.toString()+