aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-04-09 04:26:20 +0200
committerSven Gothel <[email protected]>2022-04-09 04:26:20 +0200
commit85e4513aa9a2f39ff77b67ddc7e07df7178a1a75 (patch)
tree48644c2c5f626f80aba1e8a70055ffd2f755c386 /src
parent6f759a2f91a88a93946f08bc109f7b4945814b54 (diff)
BTDevice: Update btRole = !adapter.getRole() when clearData() @ disconnected and update() @ found or connected
This ensures proper role even if device has not been removed and roles have changed.
Diffstat (limited to 'src')
-rw-r--r--src/direct_bt/BTDevice.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 8c7951ac..f5347a4c 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -141,6 +141,7 @@ void BTDevice::clearData() noexcept {
ERR_PRINT("Device still connected: %s", toString().c_str());
return;
}
+ btRole = !adapter.getRole(); // update role
// l2cap_att->close(); // already done
// ts_last_discovery = 0; // leave
// ts_last_update = 0; // leave
@@ -164,6 +165,8 @@ void BTDevice::clearData() noexcept {
EIRDataType BTDevice::update(EInfoReport const & data) noexcept {
const std::lock_guard<std::mutex> lock(mtx_eir); // RAII-style acquire and relinquish via destructor
+ btRole = !adapter.getRole(); // update role
+
// Update eir CoW style
std::shared_ptr<EInfoReport> eir_new( std::make_shared<EInfoReport>( *eir ) );
EIRDataType res0 = eir_new->set(data);