Fix connecting remotely when located in a foreign WiFi network
This commit is contained in:
parent
94b00d30f4
commit
e7885c73b1
@ -499,14 +499,12 @@ void NymeaConnection::connectInternal(NymeaHost *host)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_availableBearerTypes.testFlag(Connection::BearerTypeCloud)) {
|
||||
Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
||||
if (wanConnection) {
|
||||
qDebug() << "Best candidate WAN connection:" << wanConnection->url();
|
||||
connectInternal(wanConnection);
|
||||
} else {
|
||||
qDebug() << "No available WAN connection to" << host->name();
|
||||
}
|
||||
Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
|
||||
if (wanConnection) {
|
||||
qDebug() << "Best candidate WAN connection:" << wanConnection->url();
|
||||
connectInternal(wanConnection);
|
||||
} else {
|
||||
qDebug() << "No available WAN connection to" << host->name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -207,10 +207,18 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
|
||||
bool hasReachableConnection = false;
|
||||
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();
|
||||
// Either enable a connection when the Bearer type is directly available
|
||||
if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) {
|
||||
hasReachableConnection = true;
|
||||
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) {
|
||||
return false;
|
||||
|
||||
@ -39,6 +39,12 @@ Page {
|
||||
|
||||
// Load current index from settings
|
||||
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
|
||||
tabSettings.currentMainViewIndex = Qt.binding(function() { return root.currentViewIndex; });
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ Item {
|
||||
property var tabSettings: Settings {
|
||||
category: "tabSettings" + index
|
||||
property string lastConnectedHost
|
||||
property int currentMainViewIndex: 0
|
||||
property int currentMainViewIndex: -1
|
||||
}
|
||||
|
||||
Engine {
|
||||
@ -97,6 +97,13 @@ Item {
|
||||
value: "cloudEnvironment" in app ? app.cloudEnvironment : settings.cloudEnvironment
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: discovey
|
||||
property: "discovering"
|
||||
when: engine.connection.currentHost === null
|
||||
value: true
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
if (tabSettings.lastConnectedHost.length > 0) {
|
||||
print("Last connected host was", tabSettings.lastConnectedHost)
|
||||
|
||||
Reference in New Issue
Block a user