summaryrefslogtreecommitdiffstats
path: root/src/direct_bt/SMPHandler.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-11-15 07:27:17 +0100
committerSven Gothel <[email protected]>2020-11-15 07:27:17 +0100
commit94279b636cb59e27307656604edb77733c62d944 (patch)
tree58a11986b4ebaa6aa221de629e9d0b425433fe44 /src/direct_bt/SMPHandler.cpp
parent9c845700a73664806d58b26b332062aa2e946730 (diff)
L2CAPComm: Allow multiple open/close cycles during lifetime, required to re-establish l2cap channel on changed security/encryption
- DBTDevice -- Aggregating L2CAPComm instance, open/close and passing to GATTHandler -- add LEFeatures le_features field, incl notify update hook
Diffstat (limited to 'src/direct_bt/SMPHandler.cpp')
-rw-r--r--src/direct_bt/SMPHandler.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/direct_bt/SMPHandler.cpp b/src/direct_bt/SMPHandler.cpp
index 89158d5f..74a08ceb 100644
--- a/src/direct_bt/SMPHandler.cpp
+++ b/src/direct_bt/SMPHandler.cpp
@@ -53,6 +53,7 @@ extern "C" {
#include "SMPHandler.hpp"
#include "DBTDevice.hpp"
+#include "DBTAdapter.hpp"
using namespace direct_bt;
@@ -80,7 +81,7 @@ std::shared_ptr<DBTDevice> SMPHandler::getDeviceChecked() const {
}
bool SMPHandler::validateConnected() noexcept {
- bool l2capIsConnected = l2cap.isConnected();
+ bool l2capIsConnected = l2cap.isOpen();
bool l2capHasIOError = l2cap.hasIOError();
if( has_ioerror || l2capHasIOError ) {
@@ -157,8 +158,8 @@ void SMPHandler::l2capReaderThreadImpl() {
SMPHandler::SMPHandler(const std::shared_ptr<DBTDevice> &device) noexcept
: env(SMPEnv::get()),
wbr_device(device), deviceString(device->getAddressString()), rbuffer(number(Defaults::SMP_MTU_BUFFER_SZ)),
- l2cap(*device, L2CAP_PSM_UNDEF, L2CAP_CID_SMP),
- is_connected(true), has_ioerror(false),
+ l2cap(device->getAdapter().getAddress(), L2CAP_PSM_UNDEF, L2CAP_CID_SMP),
+ is_connected(l2cap.open(*device)), has_ioerror(false),
smpPDURing(env.SMPPDU_RING_CAPACITY), l2capReaderShallStop(false),
l2capReaderThreadId(0), l2capReaderRunning(false),
mtu(number(Defaults::MIN_SMP_MTU))
@@ -203,7 +204,7 @@ bool SMPHandler::disconnect(const bool disconnectDevice, const bool ioErrorCause
PERF3_TS_T0();
// Interrupt SM's L2CAP::connect(..) and L2CAP::read(..), avoiding prolonged hang
// and pull all underlying l2cap read operations!
- l2cap.disconnect();
+ l2cap.close();
// Avoid disconnect re-entry -> potential deadlock
bool expConn = true; // C++11, exp as value since C++20