diff options
author | Sven Gothel <[email protected]> | 2020-06-25 07:59:40 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-25 07:59:40 +0200 |
commit | 5d63b10a7628a4f58030dc0a206cde3aed8ccae0 (patch) | |
tree | 1baee0c3dab4e1638f9687f70f1945112d34e2f1 /src/direct_bt | |
parent | e848c9b32aecf2cd263da622b9030960389426fa (diff) |
DBTDevice, GATTHandler, L2CAPComm: Use INFO_PRINT on disconnect, allowing analyzing disconnect behavior in migration
Diffstat (limited to 'src/direct_bt')
-rw-r--r-- | src/direct_bt/DBTDevice.cpp | 6 | ||||
-rw-r--r-- | src/direct_bt/GATTHandler.cpp | 10 | ||||
-rw-r--r-- | src/direct_bt/L2CAPComm.cpp | 6 |
3 files changed, 12 insertions, 10 deletions
diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp index bb339e9e..bb71c8d1 100644 --- a/src/direct_bt/DBTDevice.cpp +++ b/src/direct_bt/DBTDevice.cpp @@ -371,7 +371,7 @@ void DBTDevice::notifyDisconnected() { bool DBTDevice::disconnect(const bool sentFromManager, const bool ioErrorCause, const HCIStatusCode reason) { const std::lock_guard<std::recursive_mutex> lock_conn(mtx_connect); // RAII-style acquire and relinquish via destructor - DBG_PRINT("DBTDevice::disconnect: isConnected %d, sentFromManager %d, ioError %d, reason 0x%X (%s), gattHandler %d, hciConnHandle %d", + INFO_PRINT("DBTDevice::disconnect: Start: isConnected %d, sentFromManager %d, ioError %d, reason 0x%X (%s), gattHandler %d, hciConnHandle %d", isConnected.load(), sentFromManager, ioErrorCause, static_cast<uint8_t>(reason), getHCIStatusCodeString(reason).c_str(), (nullptr != gattHandler), (0 != hciConnHandle)); disconnectGATT(); @@ -420,6 +420,7 @@ skip_hci_disconnect: exit: adapter.removeConnectedDevice(*this); + INFO_PRINT("DBTDevice::disconnect: End: isConnected %d, sentFromManager %d, ioError %d", isConnected.load(), sentFromManager, ioErrorCause); return res; } @@ -516,10 +517,11 @@ std::shared_ptr<GenericAccess> DBTDevice::getGATTGenericAccess() { void DBTDevice::disconnectGATT() { const std::lock_guard<std::recursive_mutex> lock(mtx_gatt); // RAII-style acquire and relinquish via destructor + INFO_PRINT("DBTDevice::disconnectGATT: Start: gattHandle %d", (nullptr!=gattHandler)); if( nullptr != gattHandler ) { - DBG_PRINT("DBTDevice::disconnectGATT: Disconnecting..."); // interrupt GATT's L2CAP ::connect(..), avoiding prolonged hang gattHandler->disconnect(false /* disconnectDevice */, false /* ioErrorCause */); gattHandler = nullptr; } + INFO_PRINT("DBTDevice::disconnectGATT: End"); } diff --git a/src/direct_bt/GATTHandler.cpp b/src/direct_bt/GATTHandler.cpp index dac264d5..f44feedf 100644 --- a/src/direct_bt/GATTHandler.cpp +++ b/src/direct_bt/GATTHandler.cpp @@ -262,12 +262,12 @@ bool GATTHandler::connect() { bool expConn = false; // C++11, exp as value since C++20 if( !isConnected.compare_exchange_strong(expConn, true) ) { // already connected - DBG_PRINT("GATTHandler::connect: Already connected: GattHandler[%s], l2cap[%s]: %s", + INFO_PRINT("GATTHandler::connect: Already connected: GattHandler[%s], l2cap[%s]: %s", getStateString().c_str(), l2cap.getStateString().c_str(), device->toString().c_str()); return true; } hasIOError = false; - DBG_PRINT("GATTHandler::connect: Start: GattHandler[%s], l2cap[%s]: %s", + INFO_PRINT("GATTHandler::connect: Start: GattHandler[%s], l2cap[%s]: %s", getStateString().c_str(), l2cap.getStateString().c_str(), device->toString().c_str()); if( !l2cap.connect() || !validateConnected() ) { @@ -308,13 +308,13 @@ bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCaus bool expConn = true; // C++11, exp as value since C++20 if( !isConnected.compare_exchange_strong(expConn, false) ) { // not connected - DBG_PRINT("GATTHandler::disconnect: Not connected: disconnectDevice %d, ioErrorCause %d: GattHandler[%s], l2cap[%s]: %s", + INFO_PRINT("GATTHandler::disconnect: Not connected: disconnectDevice %d, ioErrorCause %d: GattHandler[%s], l2cap[%s]: %s", disconnectDevice, ioErrorCause, getStateString().c_str(), l2cap.getStateString().c_str(), device->toString().c_str()); l2cap.disconnect(); // interrupt GATT's L2CAP ::connect(..), avoiding prolonged hang return false; } hasIOError = false; - DBG_PRINT("GATTHandler::disconnect: Start: disconnectDevice %d, ioErrorCause %d: GattHandler[%s], l2cap[%s]: %s", + INFO_PRINT("GATTHandler::disconnect: Start: disconnectDevice %d, ioErrorCause %d: GattHandler[%s], l2cap[%s]: %s", disconnectDevice, ioErrorCause, getStateString().c_str(), l2cap.getStateString().c_str(), device->toString().c_str()); l2cap.disconnect(); // interrupt GATT's L2CAP ::connect(..), avoiding prolonged hang @@ -344,7 +344,7 @@ bool GATTHandler::disconnect(const bool disconnectDevice, const bool ioErrorCaus device->disconnect(false /* sentFromManager */, ioErrorCause, reason); } - WARN_PRINT("GATTHandler::disconnect End"); + INFO_PRINT("GATTHandler::disconnect: End"); return true; } diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp index 908e5786..e5e5fce1 100644 --- a/src/direct_bt/L2CAPComm.cpp +++ b/src/direct_bt/L2CAPComm.cpp @@ -171,12 +171,12 @@ failure: bool L2CAPComm::disconnect() { bool expConn = true; // C++11, exp as value since C++20 if( !isConnected.compare_exchange_strong(expConn, false) ) { - DBG_PRINT("L2CAPComm::disconnect: Not connected: %s, dd %d, %s, psm %u, cid %u, pubDevice %d", + INFO_PRINT("L2CAPComm::disconnect: Not connected: %s, dd %d, %s, psm %u, cid %u, pubDevice %d", getStateString().c_str(), _dd.load(), device->getAddress().toString().c_str(), psm, cid, pubaddr); return false; } hasIOError = false; - DBG_PRINT("L2CAPComm::disconnect: Start: %s, dd %d, %s, psm %u, cid %u, pubDevice %d", + INFO_PRINT("L2CAPComm::disconnect: Start: %s, dd %d, %s, psm %u, cid %u, pubDevice %d", getStateString().c_str(), _dd.load(), device->getAddress().toString().c_str(), psm, cid, pubaddr); interruptFlag = true; @@ -196,7 +196,7 @@ bool L2CAPComm::disconnect() { l2cap_close_dev(_dd); _dd = -1; interruptFlag = false; - DBG_PRINT("L2CAPComm::disconnect: End dd %d", _dd.load()); + INFO_PRINT("L2CAPComm::disconnect: End: dd %d", _dd.load()); return true; } |