summaryrefslogtreecommitdiff
path: root/saltoqd/toqconnection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'saltoqd/toqconnection.cpp')
-rw-r--r--saltoqd/toqconnection.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/saltoqd/toqconnection.cpp b/saltoqd/toqconnection.cpp
index 4cc1d3e..6c1035e 100644
--- a/saltoqd/toqconnection.cpp
+++ b/saltoqd/toqconnection.cpp
@@ -6,6 +6,8 @@
#include "toqconnection.h"
static const int HEADER_LENGTH = 10;
+static const int FIRST_CONNECTION_INTERVAL = 1000;
+static const int RETRY_CONNECTION_INTERVAL = 30000;
ToqConnection::ToqConnection(QObject *parent) :
QObject(parent),
@@ -17,7 +19,6 @@ ToqConnection::ToqConnection(QObject *parent) :
this, &ToqConnection::tryConnect);
_reconnectTimer->setSingleShot(true);
- _reconnectTimer->setInterval(1000);
}
QString ToqConnection::nameOfEndpoint(Endpoint ep)
@@ -57,7 +58,7 @@ void ToqConnection::setAddress(const QBluetoothAddress &address)
if (isConnected()) {
_socket->disconnectFromService();
} else {
- _reconnectTimer->start();
+ _reconnectTimer->start(FIRST_CONNECTION_INTERVAL);
}
}
}
@@ -157,7 +158,9 @@ void ToqConnection::handleSocketDisconnected()
qDebug() << "Disconnected";
_socket->deleteLater();
_socket = 0;
- _reconnectTimer->start();
+ if (!_address.isNull()) {
+ _reconnectTimer->start(RETRY_CONNECTION_INTERVAL);
+ }
emit disconnected();
emit connectedChanged();
}