Merge PR #155: More reconnect tuning
This commit is contained in:
commit
b3c38a2052
@ -11,6 +11,7 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "nymeatransportinterface.h"
|
||||
|
||||
@ -29,6 +30,12 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
|
||||
updateActiveBearers();
|
||||
});
|
||||
|
||||
QGuiApplication *app = static_cast<QGuiApplication*>(QGuiApplication::instance());
|
||||
QObject::connect(app, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) {
|
||||
qDebug() << "Application state changed to:" << state;
|
||||
updateActiveBearers();
|
||||
});
|
||||
|
||||
updateActiveBearers();
|
||||
}
|
||||
|
||||
@ -130,7 +137,7 @@ Connection *NymeaConnection::currentConnection() const
|
||||
void NymeaConnection::sendData(const QByteArray &data)
|
||||
{
|
||||
if (connected()) {
|
||||
// qDebug() << "sending data:" << data;
|
||||
qDebug() << "sending data:" << data;
|
||||
m_currentTransport->sendData(data);
|
||||
} else {
|
||||
qWarning() << "Connection: Not connected. Cannot send.";
|
||||
@ -328,14 +335,16 @@ void NymeaConnection::onDisconnected()
|
||||
t->deleteLater();
|
||||
|
||||
if (!m_currentTransport && m_transportCandidates.isEmpty()) {
|
||||
qDebug() << "Last connection dropped. Trying to reconnect..";
|
||||
qDebug() << "Last connection dropped.";
|
||||
QTimer::singleShot(1000, this, [this](){
|
||||
if (m_currentHost) {
|
||||
qDebug() << "Trying to reconnect..";
|
||||
connectInternal(m_currentHost);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
qDebug() << "Current transport:" << m_currentTransport << "Remaining connections:" << m_transportCandidates.count() << "Current host:" << m_currentHost;
|
||||
return;
|
||||
}
|
||||
m_transportCandidates.remove(m_currentTransport);
|
||||
@ -357,7 +366,7 @@ void NymeaConnection::onDisconnected()
|
||||
emit connectedChanged(false);
|
||||
}
|
||||
|
||||
if (!m_currentTransport) {
|
||||
if (!m_currentHost) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ TEMPLATE=app
|
||||
TARGET=nymea-app
|
||||
include(../config.pri)
|
||||
|
||||
QT += network qml quick quickcontrols2 svg websockets bluetooth charts
|
||||
QT += network qml quick quickcontrols2 svg websockets bluetooth charts gui-private
|
||||
|
||||
INCLUDEPATH += $$top_srcdir/libnymea-common \
|
||||
$$top_srcdir/libnymea-app-core
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#include "platformhelper.h"
|
||||
|
||||
|
||||
PlatformHelper::PlatformHelper(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,7 @@ ApplicationWindow {
|
||||
visibility: ApplicationWindow.AutomaticVisibility
|
||||
font: Qt.application.font
|
||||
|
||||
|
||||
// Those variables must be present in the Style
|
||||
title: appName
|
||||
Material.primary: primaryColor
|
||||
@ -49,6 +50,7 @@ ApplicationWindow {
|
||||
RootItem {
|
||||
id: rootItem
|
||||
anchors.fill: parent
|
||||
anchors.topMargin: PlatformHelper.getSafeAreaMargins(app)
|
||||
}
|
||||
|
||||
NymeaDiscovery {
|
||||
|
||||
Reference in New Issue
Block a user