diff options
author | Sven Gothel <[email protected]> | 2020-09-23 03:03:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-09-23 03:03:47 +0200 |
commit | 9b40025a1d5b192c215f8ee4c4315f940e063876 (patch) | |
tree | c270a57b79578b83c843d7ff62cdb60f0dd9056c /src | |
parent | 7c4578c198e1c4ed49d15097cf98bbe3ece86b31 (diff) |
HCIHandler::disconnect: Move 'manual' sending of last-resort disconnected event to caller (DBTDevice) to cover HCIHandler == nullptr (power-off)
Diffstat (limited to 'src')
-rw-r--r-- | src/direct_bt/DBTDevice.cpp | 14 | ||||
-rw-r--r-- | src/direct_bt/HCIHandler.cpp | 7 |
2 files changed, 8 insertions, 13 deletions
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp index 596908c8..cf5f2867 100644 --- a/src/direct_bt/DBTDevice.cpp +++ b/src/direct_bt/DBTDevice.cpp @@ -459,12 +459,6 @@ HCIStatusCode DBTDevice::disconnect(const bool fromDisconnectCB, const bool ioEr if( nullptr == hci ) { DBG_PRINT("DBTDevice::disconnect: Skip disconnect: HCI not available: %s", toString().c_str()); res = HCIStatusCode::INTERNAL_FAILURE; - - adapter.mgmtEvDeviceDisconnectedHCI( - std::shared_ptr<MgmtEvent>( - new MgmtEvtDeviceDisconnected(adapter.dev_id, address, addressType, reason, hciConnHandle.load()) - ) ); - goto exit; } @@ -478,6 +472,14 @@ HCIStatusCode DBTDevice::disconnect(const bool fromDisconnectCB, const bool ioEr } exit: + if( ioErrorCause || HCIStatusCode::SUCCESS != res ) { + // In case of an ioError (lost-connection), power-off or already pulled HCIHandler, + // don't wait for the lagging DISCONN_COMPLETE event but send it directly. + adapter.mgmtEvDeviceDisconnectedHCI( + std::shared_ptr<MgmtEvent>( + new MgmtEvtDeviceDisconnected(adapter.dev_id, address, addressType, reason, hciConnHandle.load()) + ) ); + } WORDY_PRINT("DBTDevice::disconnect: End: status %s, handle 0x%X, isConnected %d/%d, fromDisconnectCB %d, ioError %d on %s", getHCIStatusCodeString(res).c_str(), hciConnHandle.load(), allowDisconnect.load(), isConnected.load(), fromDisconnectCB, ioErrorCause, diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp index f88df374..7f679cb3 100644 --- a/src/direct_bt/HCIHandler.cpp +++ b/src/direct_bt/HCIHandler.cpp @@ -717,13 +717,6 @@ HCIStatusCode HCIHandler::disconnect(const bool ioErrorCause, std::shared_ptr<HCIEvent> ev = processCommandStatus(req0, &status); } - if( ioErrorCause ) { - // In case of an ioError (lost-connection), don't wait for the lagging - // DISCONN_COMPLETE event but send it directly. - removeTrackerConnection(conn); - MgmtEvtDeviceDisconnected *e = new MgmtEvtDeviceDisconnected(dev_id, peer_bdaddr, peer_mac_type, reason, conn_handle); - sendMgmtEvent(std::shared_ptr<MgmtEvent>(e)); - } return status; } |