summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api/direct_bt/L2CAPComm.hpp13
-rw-r--r--src/direct_bt/BTGattHandler.cpp5
-rw-r--r--src/direct_bt/L2CAPComm.cpp6
3 files changed, 16 insertions, 8 deletions
diff --git a/api/direct_bt/L2CAPComm.hpp b/api/direct_bt/L2CAPComm.hpp
index 31490c68..ecd4ed67 100644
--- a/api/direct_bt/L2CAPComm.hpp
+++ b/api/direct_bt/L2CAPComm.hpp
@@ -115,6 +115,7 @@ namespace direct_bt {
public:
static std::string getStateString(bool isOpen, bool hasIOError) noexcept;
static std::string getStateString(bool isOpen, bool isInterrupted, bool hasIOError) noexcept;
+ static std::string getStateString(bool isOpen, bool irqed_int, bool irqed_ext, bool hasIOError) noexcept;
/** Utilized to query for external interruption, whether device is still connected etc. */
typedef jau::FunctionDef<bool, int /* dummy*/> get_boolean_callback_t;
@@ -145,6 +146,12 @@ namespace direct_bt {
bool setBTSecurityLevelImpl(const BTSecurityLevel sec_level, const BDAddressAndType& remoteAddressAndType) noexcept;
BTSecurityLevel getBTSecurityLevelImpl(const BDAddressAndType& remoteAddressAndType) noexcept;
+ /** Returns true if interrupted by internal cause. */
+ bool interrupted_int() const noexcept { return interrupted_intern; }
+
+ /** Returns true if interrupted by external cause. */
+ bool interrupted_ext() const noexcept { return !is_interrupted_extern.isNullType() && is_interrupted_extern(0/*dummy*/); }
+
public:
L2CAPComm(const uint16_t adev_id, const BDAddressAndType& localAddressAndType, const L2CAP_PSM psm, const L2CAP_CID cid) noexcept;
@@ -160,7 +167,7 @@ namespace direct_bt {
void set_interrupted_query(get_boolean_callback_t is_interrupted_cb) { is_interrupted_extern = is_interrupted_cb; }
/** Returns true if interrupted by internal or external cause, hence shall stop connecting and reading. */
- bool interrupted() const noexcept { return interrupted_intern || ( !is_interrupted_extern.isNullType() && is_interrupted_extern(0/*dummy*/) ); }
+ bool interrupted() const noexcept { return interrupted_int() || interrupted_ext(); }
/** Closing the L2CAP socket, see specializations. */
virtual bool close() noexcept = 0;
@@ -247,7 +254,7 @@ namespace direct_bt {
bool close() noexcept override;
bool hasIOError() const noexcept { return has_ioerror; }
- std::string getStateString() const noexcept override { return L2CAPComm::getStateString(is_open_, interrupted(), has_ioerror); }
+ std::string getStateString() const noexcept override { return L2CAPComm::getStateString(is_open_, interrupted_int(), interrupted_ext(), has_ioerror); }
/** Return the recursive write mutex for multithreading access. */
std::recursive_mutex & mutex_write() noexcept { return mtx_write; }
@@ -309,7 +316,7 @@ namespace direct_bt {
std::unique_ptr<L2CAPClient> accept() noexcept;
- std::string getStateString() const noexcept override { return L2CAPComm::getStateString(is_open_, interrupted(), false /* has_ioerror */); }
+ std::string getStateString() const noexcept override { return L2CAPComm::getStateString(is_open_, interrupted_int(), interrupted_ext(), false /* has_ioerror */); }
std::string toString() const noexcept override;
};
diff --git a/src/direct_bt/BTGattHandler.cpp b/src/direct_bt/BTGattHandler.cpp
index 714937ea..44853f24 100644
--- a/src/direct_bt/BTGattHandler.cpp
+++ b/src/direct_bt/BTGattHandler.cpp
@@ -583,8 +583,6 @@ BTGattHandler::BTGattHandler(const BTDeviceRef &device, L2CAPClient& l2cap_att,
is_connected = false;
return;
}
- DBG_PRINT("GATTHandler::ctor: Start Connect: GattHandler[%s], l2cap[%s]: %s",
- getStateString().c_str(), l2cap.getStateString().c_str(), toString().c_str());
/**
* We utilize DBTManager's mgmthandler_sigaction SIGALRM handler,
@@ -594,6 +592,9 @@ BTGattHandler::BTGattHandler(const BTDeviceRef &device, L2CAPClient& l2cap_att,
l2cap.set_interrupted_query( jau::bindMemberFunc(this, &BTGattHandler::l2capReaderInterrupted) );
l2cap_reader_service.start();
+ DBG_PRINT("GATTHandler::ctor: Started: GattHandler[%s], l2cap[%s]: %s",
+ getStateString().c_str(), l2cap.getStateString().c_str(), toString().c_str());
+
if( GATTRole::Client == getRole() ) {
// MTU to be negotiated via initClientGatt() from this GATT client later
serverMTU = number(Defaults::MAX_ATT_MTU);
diff --git a/src/direct_bt/L2CAPComm.cpp b/src/direct_bt/L2CAPComm.cpp
index cc2631f4..c8c52295 100644
--- a/src/direct_bt/L2CAPComm.cpp
+++ b/src/direct_bt/L2CAPComm.cpp
@@ -81,10 +81,10 @@ std::string L2CAPComm::getStateString(bool isOpen, bool hasIOError) noexcept {
", errno "+std::to_string(errno)+" ("+std::string(strerror(errno))+")]";
}
-std::string L2CAPComm::getStateString(bool isOpen, bool isInterrupted, bool hasIOError) noexcept {
+std::string L2CAPComm::getStateString(bool isOpen, bool irqed_int, bool irqed_ext, bool hasIOError) noexcept {
return "State[open "+std::to_string(isOpen)+
- ", irqed "+std::to_string(isInterrupted)+
- ", ioerr "+std::to_string(hasIOError)+
+ ", irqed "+std::to_string(irqed_int || irqed_ext)+" [int "+std::to_string(irqed_int)+", ext "+std::to_string(irqed_ext)+
+ "], ioerr "+std::to_string(hasIOError)+
", errno "+std::to_string(errno)+" ("+std::string(strerror(errno))+")]";
}