aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/BTGattHandler.hpp2
-rw-r--r--src/direct_bt/BTGattHandler.cpp15
2 files changed, 16 insertions, 1 deletions
diff --git a/api/direct_bt/BTGattHandler.hpp b/api/direct_bt/BTGattHandler.hpp
index 29ed24dd..bd561956 100644
--- a/api/direct_bt/BTGattHandler.hpp
+++ b/api/direct_bt/BTGattHandler.hpp
@@ -475,6 +475,8 @@ namespace direct_bt {
void l2capReaderWork(jau::service_runner& sr) noexcept;
void l2capReaderEndLocked(jau::service_runner& sr) noexcept;
+ bool l2capReaderInterrupted(int dummy) /* const */ noexcept;
+
/**
* BT Core Spec v5.2: Vol 3, Part G GATT: 3.4.2 MTU Exchange
*
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() ) {