aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt/BTGattHandler.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-04-23 04:38:59 +0200
committerSven Gothel <[email protected]>2022-04-23 04:45:25 +0200
commit350af25788415551960e424963092188bc04ded3 (patch)
treeabde0060decf1e39588c7c532ecbc97375da3021 /src/direct_bt/BTGattHandler.cpp
parent4f5aee985e56feeb29a0f5658c3ccbf5b0556f0c (diff)
L2CAPClient::read(): Add READ_TIMEOUT and simplify branching on result in read() and caller; If INTERRUPTED -> service_runner.set_shall_stop() if not set (external irq)
Diffstat (limited to 'src/direct_bt/BTGattHandler.cpp')
-rw-r--r--src/direct_bt/BTGattHandler.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 44853f24..1534a8ad 100644
--- a/src/direct_bt/BTGattHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -518,14 +518,24 @@ void BTGattHandler::l2capReaderWork(jau::service_runner& sr) noexcept {
} else {
ERR_PRINT("Unhandled: %s", attPDU->toString().c_str());
}
- } else if( 0 > len && ETIMEDOUT != errno && len != L2CAPClient::number(L2CAPClient::RWExitCode::INTERRUPTED) ) { // expected exits
- IRQ_PRINT("GATTHandler::reader: l2cap read: Error res %d (%s); %s",
- len, L2CAPClient::getRWExitCodeString(len).c_str(), getStateString().c_str());
- sr.set_shall_stop();
- has_ioerror = true;
- } else if( len != L2CAPClient::number(L2CAPClient::RWExitCode::POLL_TIMEOUT) ) { // expected POLL_TIMEOUT if idle
+ } else if( len == L2CAPClient::number(L2CAPClient::RWExitCode::INTERRUPTED) ) {
WORDY_PRINT("GATTHandler::reader: l2cap read: IRQed res %d (%s); %s",
len, L2CAPClient::getRWExitCodeString(len).c_str(), getStateString().c_str());
+ if( !sr.shall_stop() ) {
+ // need to stop service_runner if interrupted externally
+ sr.set_shall_stop();
+ }
+ } else if( len != L2CAPClient::number(L2CAPClient::RWExitCode::POLL_TIMEOUT) &&
+ len != L2CAPClient::number(L2CAPClient::RWExitCode::READ_TIMEOUT) ) { // expected TIMEOUT if idle
+ if( 0 > len ) { // actual error case
+ IRQ_PRINT("GATTHandler::reader: l2cap read: Error res %d (%s); %s",
+ len, L2CAPClient::getRWExitCodeString(len).c_str(), getStateString().c_str());
+ sr.set_shall_stop();
+ has_ioerror = true;
+ } else { // zero size
+ WORDY_PRINT("GATTHandler::reader: l2cap read: Zero res %d (%s); %s",
+ len, L2CAPClient::getRWExitCodeString(len).c_str(), getStateString().c_str());
+ }
}
}