diff options
author | Sven Gothel <[email protected]> | 2022-04-22 00:40:25 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-04-22 00:40:25 +0200 |
commit | f233dd90175762586fe4d38a1274ba21be36d716 (patch) | |
tree | 9ea294d92ab80afa3906dd72298bbe4813ba8faf /src/direct_bt/BTGattHandler.cpp | |
parent | b617adf56ae724e8898935682cf269c8679b6e84 (diff) |
BTGattHandler: Widen L2Cap 'interrupted' query to include disconnected device, i.e. avoid error logs when disconnected in reader and bail out even earlier
Diffstat (limited to 'src/direct_bt/BTGattHandler.cpp')
-rw-r--r-- | src/direct_bt/BTGattHandler.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp index d8f857cb..8fc0259a 100644 --- a/src/direct_bt/BTGattHandler.cpp +++ b/src/direct_bt/BTGattHandler.cpp @@ -537,6 +537,18 @@ void BTGattHandler::l2capReaderEndLocked(jau::service_runner& sr) noexcept { #endif } +bool BTGattHandler::l2capReaderInterrupted(int dummy) /* const */ noexcept { + (void)dummy; + if( l2cap_reader_service.shall_stop() || !is_connected ) { + return true; + } + BTDeviceRef device = getDeviceUnchecked(); + if( nullptr == device ) { + return true; + } + return !device->getConnected(); +} + BTGattHandler::BTGattHandler(const BTDeviceRef &device, L2CAPClient& l2cap_att, const int32_t supervision_timeout_) noexcept : supervision_timeout(supervision_timeout_), env(BTGattEnv::get()), @@ -569,7 +581,8 @@ BTGattHandler::BTGattHandler(const BTDeviceRef &device, L2CAPClient& l2cap_att, * We utilize DBTManager's mgmthandler_sigaction SIGALRM handler, * as we only can install one handler. */ - l2cap.set_interrupted_query( jau::bindMemberFunc(&l2cap_reader_service, &jau::service_runner::shall_stop2) ); + // l2cap.set_interrupted_query( jau::bindMemberFunc(&l2cap_reader_service, &jau::service_runner::shall_stop2) ); + l2cap.set_interrupted_query( jau::bindMemberFunc(this, &BTGattHandler::l2capReaderInterrupted) ); l2cap_reader_service.start(); if( GATTRole::Client == getRole() ) { |