Merge PR #146: Fix connecting remotely when located in a foreign WiFi network
This commit is contained in:
commit
4b13fe5bf8
@ -499,14 +499,12 @@ void NymeaConnection::connectInternal(NymeaHost *host)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_availableBearerTypes.testFlag(Connection::BearerTypeCloud)) {
|
Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
||||||
Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
if (wanConnection) {
|
||||||
if (wanConnection) {
|
qDebug() << "Best candidate WAN connection:" << wanConnection->url();
|
||||||
qDebug() << "Best candidate WAN connection:" << wanConnection->url();
|
connectInternal(wanConnection);
|
||||||
connectInternal(wanConnection);
|
} else {
|
||||||
} else {
|
qDebug() << "No available WAN connection to" << host->name();
|
||||||
qDebug() << "No available WAN connection to" << host->name();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -207,10 +207,18 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
|
|||||||
bool hasReachableConnection = false;
|
bool hasReachableConnection = false;
|
||||||
for (int i = 0; i < host->connections()->rowCount(); i++) {
|
for (int i = 0; i < host->connections()->rowCount(); i++) {
|
||||||
// qDebug() << "checking host for available bearer" << host->name() << host->connections()->get(i)->url() << "available bearer types:" << m_nymeaConnection->availableBearerTypes() << "hosts bearer types" << host->connections()->get(i)->bearerType();
|
// qDebug() << "checking host for available bearer" << host->name() << host->connections()->get(i)->url() << "available bearer types:" << m_nymeaConnection->availableBearerTypes() << "hosts bearer types" << host->connections()->get(i)->bearerType();
|
||||||
|
// Either enable a connection when the Bearer type is directly available
|
||||||
if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) {
|
if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) {
|
||||||
hasReachableConnection = true;
|
hasReachableConnection = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// or enable it if it is Cloud and we have access to LAN or WIFI
|
||||||
|
if (host->connections()->get(i)->bearerType() == Connection::BearerTypeCloud) {
|
||||||
|
if (m_nymeaConnection->availableBearerTypes().testFlag(Connection::BearerTypeWifi) || m_nymeaConnection->availableBearerTypes().testFlag(Connection::BearerTypeEthernet)) {
|
||||||
|
hasReachableConnection = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!hasReachableConnection) {
|
if (!hasReachableConnection) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -39,6 +39,12 @@ Page {
|
|||||||
|
|
||||||
// Load current index from settings
|
// Load current index from settings
|
||||||
currentViewIndex = tabSettings.currentMainViewIndex;
|
currentViewIndex = tabSettings.currentMainViewIndex;
|
||||||
|
|
||||||
|
// If setting is not initialized yet, init to "Things" page (might be 0 or 1, depending whether we have tags support)
|
||||||
|
if (currentViewIndex === -1) {
|
||||||
|
currentViewIndex = engine.jsonRpcClient.ensureServerVersion(1.6) ? 1 : 0
|
||||||
|
}
|
||||||
|
|
||||||
// and set up a binding to sync changes back to the settings
|
// and set up a binding to sync changes back to the settings
|
||||||
tabSettings.currentMainViewIndex = Qt.binding(function() { return root.currentViewIndex; });
|
tabSettings.currentMainViewIndex = Qt.binding(function() { return root.currentViewIndex; });
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,7 @@ Item {
|
|||||||
property var tabSettings: Settings {
|
property var tabSettings: Settings {
|
||||||
category: "tabSettings" + index
|
category: "tabSettings" + index
|
||||||
property string lastConnectedHost
|
property string lastConnectedHost
|
||||||
property int currentMainViewIndex: 0
|
property int currentMainViewIndex: -1
|
||||||
}
|
}
|
||||||
|
|
||||||
Engine {
|
Engine {
|
||||||
@ -97,6 +97,13 @@ Item {
|
|||||||
value: "cloudEnvironment" in app ? app.cloudEnvironment : settings.cloudEnvironment
|
value: "cloudEnvironment" in app ? app.cloudEnvironment : settings.cloudEnvironment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binding {
|
||||||
|
target: discovey
|
||||||
|
property: "discovering"
|
||||||
|
when: engine.connection.currentHost === null
|
||||||
|
value: true
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (tabSettings.lastConnectedHost.length > 0) {
|
if (tabSettings.lastConnectedHost.length > 0) {
|
||||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||||
|
|||||||
Reference in New Issue
Block a user