diff options
author | Sven Gothel <[email protected]> | 2020-06-24 20:20:33 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-24 20:20:33 +0200 |
commit | 766ef519b8ada7711f059ea28f3073f50934b3f0 (patch) | |
tree | 57f6ce8458d67fddd78b1226713ec1dbb1b97a21 /api | |
parent | 2a6a4569c992d3487fba497c92e361e95a498e17 (diff) |
GATTHandler::disconnect(..): Expose full parametrized variant only, adding 'bool disconnectDevice'
disconnectDevice shall not always occure w/ GATTHandler::disconnect, i.e.:
- when issuing DBTDevice::disconnectGATT() as it is already called from DBTDevice::disconnect(..)
- via GATTHandler dtor
This avoid unnecessary recursions, which should fail anyways as first disconnect
shall make subsequent disconnect calls return early.
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/GATTHandler.hpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/api/direct_bt/GATTHandler.hpp b/api/direct_bt/GATTHandler.hpp index 336f0371..67c932fd 100644 --- a/api/direct_bt/GATTHandler.hpp +++ b/api/direct_bt/GATTHandler.hpp @@ -122,8 +122,6 @@ namespace direct_bt { */ uint16_t exchangeMTU(const uint16_t clientMaxMTU=number(Defaults::MAX_ATT_MTU)); - bool disconnect(const bool ioErrorCause); - public: GATTHandler(const std::shared_ptr<DBTDevice> & device, const int replyTimeoutMS = number(Defaults::L2CAP_COMMAND_REPLY_TIMEOUT)); @@ -137,9 +135,15 @@ namespace direct_bt { * See getServerMTU() and getUsedMTU(), the latter is in use. */ bool connect(); - bool disconnect() { - return disconnect(false /* ioErrorCause */); - } + + /** + * Disconnect this GATTHandler and optionally the associated device + * @param disconnectDevice if true, associated device will also be disconnected, otherwise not. + * @param ioErrorCause if true, reason for disconnection is an IO error + * @return true if successful, otherwise false + */ + bool disconnect(const bool disconnectDevice, const bool ioErrorCause); + bool isOpen() const { return L2CAPComm::State::Disconnected < state && l2cap.isOpen(); } uint16_t getServerMTU() const { return serverMTU; } |