aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt/BTGattHandler.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-09-23 05:55:44 +0200
committerSven Gothel <[email protected]>2021-09-23 05:55:44 +0200
commit3c000949849692021b472631b5614290a9d96863 (patch)
tree449f25dadd4b9fd2d7b7e0fcea130b44df5442f5 /src/direct_bt/BTGattHandler.cpp
parent9fe29914d60026c2d737c41e619e73f19b128711 (diff)
[BTGatt|SMP]Handler::l2capReaderThreadImpl()/send(): On R/W failue, IRQ|DBT out: Add getStateString(..) to expose errno. Fix send()..
Fix send() messages: Use proper jau::snsize_t (%d) etc ..
Diffstat (limited to 'src/direct_bt/BTGattHandler.cpp')
-rw-r--r--src/direct_bt/BTGattHandler.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 1d1c911e..41e3d9fe 100644
--- a/src/direct_bt/BTGattHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -263,11 +263,15 @@ void BTGattHandler::l2capReaderThreadImpl() {
attPDURing.putBlocking( std::move(attPDU) );
}
} else if( ETIMEDOUT != errno && !l2capReaderShallStop ) { // expected exits
- IRQ_PRINT("GATTHandler::reader: l2cap read error -> Stop; l2cap.read %d (%s)", len, L2CAPComm::getExitCodeString(len).c_str());
+ IRQ_PRINT("GATTHandler::reader: l2cap read error -> Stop; l2cap.read %d (%s); %s",
+ len, L2CAPComm::getExitCodeString(len).c_str(),
+ getStateString().c_str());
l2capReaderShallStop = true;
has_ioerror = true;
} else {
- DBG_PRINT("GATTHandler::reader: l2cap read failed: l2cap.read %d (%s)", len, L2CAPComm::getExitCodeString(len).c_str());
+ DBG_PRINT("GATTHandler::reader: l2cap read: l2cap.read %d (%s)",
+ len, L2CAPComm::getExitCodeString(len).c_str(),
+ getStateString().c_str());
}
}
{
@@ -424,21 +428,21 @@ void BTGattHandler::send(const AttPDUMsg & msg) {
}
// Thread safe l2cap.write(..) operation..
- const ssize_t res = l2cap.write(msg.pdu.get_ptr(), msg.pdu.getSize());
+ const jau::snsize_t res = l2cap.write(msg.pdu.get_ptr(), msg.pdu.getSize());
if( 0 > res ) {
- IRQ_PRINT("GATTHandler::send: l2cap write error -> disconnect: l2cap.write %d (%s); %s to %s",
- res, L2CAPComm::getExitCodeString(res).c_str(),
+ IRQ_PRINT("GATTHandler::send: l2cap write error -> disconnect: l2cap.write %d (%s); %s; %s to %s",
+ res, L2CAPComm::getExitCodeString(res).c_str(), getStateString().c_str(),
msg.toString().c_str(), toString().c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
throw BTException("GATTHandler::send: l2cap write error: req "+msg.toString()+" to "+toString(), E_FILE_LINE);
}
if( static_cast<size_t>(res) != msg.pdu.getSize() ) {
- ERR_PRINT("GATTHandler::send: l2cap write count error, %zd != %zu: %s -> disconnect: %s",
+ ERR_PRINT("GATTHandler::send: l2cap write count error, %d != %zu: %s -> disconnect: %s",
res, msg.pdu.getSize(), msg.toString().c_str(), toString().c_str());
has_ioerror = true;
disconnect(true /* disconnectDevice */, true /* ioErrorCause */); // state -> Disconnected
- throw BTException("GATTHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(res)
+ throw BTException("GATTHandler::send: l2cap write count error, "+std::to_string(res)+" != "+std::to_string(msg.pdu.getSize())
+": "+msg.toString()+" -> disconnect: "+toString(), E_FILE_LINE);
}
}