From e34f49ff20f2227ffca0515201e7493fd55ef64a Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 26 Jul 2014 22:59:39 +0200 Subject: add "requireencryption" connection option (ABI broken!) --- gatoattclient.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gatoattclient.cpp') diff --git a/gatoattclient.cpp b/gatoattclient.cpp index 6cf6d69..0bf5877 100644 --- a/gatoattclient.cpp +++ b/gatoattclient.cpp @@ -75,7 +75,8 @@ static QByteArray remove_method_signature(const char *sig) } GatoAttClient::GatoAttClient(QObject *parent) : - QObject(parent), socket(new GatoSocket(this)), cur_mtu(ATT_DEFAULT_LE_MTU), next_id(1) + QObject(parent), socket(new GatoSocket(this)), cur_mtu(ATT_DEFAULT_LE_MTU), next_id(1), + required_sec(GatoSocket::SecurityLow) { connect(socket, SIGNAL(connected()), SLOT(handleSocketConnected())); connect(socket, SIGNAL(disconnected()), SLOT(handleSocketDisconnected())); @@ -91,8 +92,9 @@ GatoSocket::State GatoAttClient::state() const return socket->state(); } -bool GatoAttClient::connectTo(const GatoAddress &addr) +bool GatoAttClient::connectTo(const GatoAddress &addr, GatoSocket::SecurityLevel sec_level) { + required_sec = sec_level; return socket->connectTo(addr, ATT_CID); } @@ -540,6 +542,10 @@ QList GatoAttClient::parseAttributeGroupData( void GatoAttClient::handleSocketConnected() { + if (socket->securityLevel() < required_sec) { + socket->setSecurityLevel(required_sec); + } + requestExchangeMTU(ATT_MAX_LE_MTU, this, SLOT(handleServerMTU(quint16))); emit connected(); } -- cgit v1.2.3