From 85e4513aa9a2f39ff77b67ddc7e07df7178a1a75 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 9 Apr 2022 04:26:20 +0200 Subject: 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. --- src/direct_bt/BTDevice.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') 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 lock(mtx_eir); // RAII-style acquire and relinquish via destructor + btRole = !adapter.getRole(); // update role + // Update eir CoW style std::shared_ptr eir_new( std::make_shared( *eir ) ); EIRDataType res0 = eir_new->set(data); -- cgit v1.2.3