Fixes in new connection code. Demo server and manual connection work again

This commit is contained in:
Michael Zanetti 2019-02-11 23:13:28 +01:00
parent f9730626ad
commit bcbeb0cf97
15 changed files with 187 additions and 87 deletions

View File

@ -235,7 +235,7 @@ void NymeaConfiguration::getConfigurationsResponse(const QVariantMap &params)
tcpServerConfigurations()->clear();
foreach (const QVariant &tcpServerVariant, params.value("params").toMap().value("tcpServerConfigurations").toList()) {
qDebug() << "tcp server config:" << tcpServerVariant;
// qDebug() << "tcp server config:" << tcpServerVariant;
QVariantMap tcpConfigMap = tcpServerVariant.toMap();
ServerConfiguration *config = new ServerConfiguration(tcpConfigMap.value("id").toString(), QHostAddress(tcpConfigMap.value("address").toString()), tcpConfigMap.value("port").toInt(), tcpConfigMap.value("authenticationEnabled").toBool(), tcpConfigMap.value("sslEnabled").toBool());
m_tcpServerConfigurations->addConfiguration(config);

View File

@ -124,10 +124,14 @@ void NymeaDiscovery::cacheHost(NymeaHost *host)
if (remoteConnection) {
connections.append(remoteConnection);
}
Connection *lanConnection = host->connections()->bestMatch(Connection::BearerTypeWifi | Connection::BearerTypeEthernet);
Connection *lanConnection = host->connections()->bestMatch(Connection::BearerTypeLan);
if (lanConnection) {
connections.append(lanConnection);
}
Connection *wanConnection = host->connections()->bestMatch(Connection::BearerTypeWan);
if (wanConnection) {
connections.append(wanConnection);
}
Connection *btConnection = host->connections()->bestMatch(Connection::BearerTypeBluetooth);
if (btConnection) {
connections.append(btConnection);

View File

@ -254,7 +254,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply)
qDebug() << "UPnP: Adding new connection to host:" << device->name() << url;
bool sslEnabled = url.scheme() == "nymeas" || url.scheme() == "wss";
QString displayName = QString("%1:%2").arg(url.host()).arg(url.port());
Connection *conn = new Connection(url, Connection::BearerTypeWifi, sslEnabled, displayName);
Connection *conn = new Connection(url, Connection::BearerTypeLan, sslEnabled, displayName);
conn->setOnline(true);
device->connections()->addConnection(conn);
}

View File

@ -126,7 +126,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry)
if (!connection) {
qDebug() << "Zeroconf: Adding new connection to host:" << host->name() << url.toString();
QString displayName = QString("%1:%2").arg(url.host()).arg(url.port());
connection = new Connection(url, Connection::BearerTypeWifi, sslEnabled, displayName);
connection = new Connection(url, Connection::BearerTypeLan, sslEnabled, displayName);
connection->setOnline(true);
host->connections()->addConnection(connection);
} else {

View File

@ -19,10 +19,12 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
m_networkConfigManager = new QNetworkConfigurationManager(this);
QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationAdded, this, [this](const QNetworkConfiguration &config){
Q_UNUSED(config)
// qDebug() << "Network configuration added:" << config.name() << config.bearerTypeName() << config.purpose();
updateActiveBearers();
});
QObject::connect(m_networkConfigManager, &QNetworkConfigurationManager::configurationRemoved, this, [this](const QNetworkConfiguration &config){
Q_UNUSED(config)
// qDebug() << "Network configuration removed:" << config.name() << config.bearerTypeName() << config.purpose();
updateActiveBearers();
});
@ -56,7 +58,7 @@ bool NymeaConnection::isTrusted(const QString &url)
return false;
}
Connection::BearerTypes NymeaConnection::availableBearerTypes() const
NymeaConnection::BearerTypes NymeaConnection::availableBearerTypes() const
{
return m_availableBearerTypes;
}
@ -97,19 +99,28 @@ void NymeaConnection::setCurrentHost(NymeaHost *host)
m_currentHost = nullptr;
}
m_currentHost = host;
emit currentHostChanged();
if (!m_currentHost) {
qDebug() << "No current host.";
return;
}
qDebug() << "Nymea host is" << m_currentHost->name() << m_currentHost->uuid();
m_connectionStatus = ConnectionStatusConnecting;
emit connectionStatusChanged();
if (m_currentHost) {
connectInternal(m_currentHost);
}
connectInternal(m_currentHost);
}
Connection *NymeaConnection::currentConnection() const
{
qDebug() << "Current connection:" << m_currentHost << m_currentTransport << m_transportCandidates.count();
qDebug() << m_transportCandidates.keys();
qDebug() << m_transportCandidates.value(m_currentTransport);
if (!m_currentHost || !m_currentTransport) {
return nullptr;
}
@ -258,8 +269,10 @@ void NymeaConnection::onError(QAbstractSocket::SocketError error)
emit connectionStatusChanged();
if (m_connectionStatus != ConnectionStatusSslUntrusted) {
QTimer::singleShot(1000, m_currentHost, [this](){
connectInternal(m_currentHost);
QTimer::singleShot(1000, this, [this](){
if (m_currentHost) {
connectInternal(m_currentHost);
}
});
}
}
@ -344,6 +357,10 @@ void NymeaConnection::onDisconnected()
emit connectedChanged(false);
}
if (!m_currentTransport) {
return;
}
// Try to reconnect, only if we're not waiting for SSL certs to be trusted.
if (m_connectionStatus != ConnectionStatusSslUntrusted) {
connectInternal(m_currentHost);
@ -352,16 +369,18 @@ void NymeaConnection::onDisconnected()
void NymeaConnection::updateActiveBearers()
{
Connection::BearerTypes availableBearerTypes;
NymeaConnection::BearerTypes availableBearerTypes;
QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active);
// qDebug() << "Network configuations:" << configs.count();
foreach (const QNetworkConfiguration &config, configs) {
qDebug() << "Candidate network config:" << config.name() << config.bearerTypeFamily() << config.bearerTypeName();
// NOTE: iOS doesn't correctly report bearer types. It'll be Unknown all the time
// availableBearerTypes.setFlag(Connection::BearerTypeUnknown);
// NOTE: iOS doesn't correctly report bearer types. It'll be Unknown all the time. Let's hardcode it to WiFi for that...
#if defined(Q_OS_IOS)
availableBearerTypes.setFlag(NymeaConnection::BearerTypeWiFi);
#else
availableBearerTypes.setFlag(qBearerTypeToNymeaBearerType(config.bearerType()));
#endif
}
// qDebug() << "Available bearers:" << availableBearerTypes;
if (m_availableBearerTypes != availableBearerTypes) {
@ -394,31 +413,6 @@ void NymeaConnection::updateActiveBearers()
}
Connection::BearerType NymeaConnection::qBearerTypeToNymeaBearerType(QNetworkConfiguration::BearerType type) const
{
switch (type) {
case QNetworkConfiguration::BearerWLAN:
return Connection::BearerTypeWifi;
case QNetworkConfiguration::BearerEthernet:
return Connection::BearerTypeEthernet;
case QNetworkConfiguration::Bearer2G:
case QNetworkConfiguration::BearerCDMA2000:
case QNetworkConfiguration::BearerWCDMA:
case QNetworkConfiguration::BearerHSPA:
case QNetworkConfiguration::BearerWiMAX:
case QNetworkConfiguration::BearerEVDO:
case QNetworkConfiguration::BearerLTE:
case QNetworkConfiguration::Bearer3G:
case QNetworkConfiguration::Bearer4G:
return Connection::BearerTypeCloud;
case QNetworkConfiguration::BearerBluetooth:
return Connection::BearerTypeBluetooth;
case QNetworkConfiguration::BearerUnknown:
return Connection::BearerTypeUnknown;
}
return Connection::BearerTypeNone;
}
bool NymeaConnection::storePem(const QUrl &host, const QByteArray &pem)
{
@ -476,8 +470,9 @@ void NymeaConnection::connect(NymeaHost *nymeaHost, Connection *connection)
void NymeaConnection::connectInternal(NymeaHost *host)
{
if (m_availableBearerTypes == Connection::BearerTypeNone) {
qDebug() << "No available bearer. Not connecting... (" << m_availableBearerTypes << ")";
qDebug() << "Connecting. Available bearer types:" << m_availableBearerTypes;
if (m_availableBearerTypes == NymeaConnection::BearerTypeNone) {
qDebug() << "No available bearer. Not connecting...";
m_connectionStatus = ConnectionStatusNoBearerAvailable;
emit connectionStatusChanged();
return;
@ -489,23 +484,39 @@ void NymeaConnection::connectInternal(NymeaHost *host)
return;
}
if (m_availableBearerTypes.testFlag(Connection::BearerTypeWifi) || m_availableBearerTypes.testFlag(Connection::BearerTypeEthernet)) {
Connection* lanConnection = host->connections()->bestMatch(Connection::BearerTypeWifi | Connection::BearerTypeEthernet);
if (m_availableBearerTypes.testFlag(NymeaConnection::BearerTypeWiFi)
|| m_availableBearerTypes.testFlag(NymeaConnection::BearerTypeEthernet)) {
Connection* lanConnection = host->connections()->bestMatch(Connection::BearerTypeLan | Connection::BearerTypeWan);
if (lanConnection) {
qDebug() << "Best candidate LAN connection:" << lanConnection->url();
qDebug() << "Best candidate LAN/WAN connection:" << lanConnection->url();
connectInternal(lanConnection);
} else {
qDebug() << "No available LAN connection to" << host->name();
qDebug() << "No available LAN/WAN connection to" << host->name();
}
} else if (m_availableBearerTypes.testFlag(NymeaConnection::BearerTypeMobileData)) {
Connection* wanConnection = host->connections()->bestMatch(Connection::BearerTypeWan);
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);
Connection* cloudConnection = host->connections()->bestMatch(Connection::BearerTypeCloud);
if (cloudConnection) {
qDebug() << "Best candidate Cloud connection:" << cloudConnection->url();
connectInternal(cloudConnection);
} else {
qDebug() << "No available WAN connection to" << host->name();
qDebug() << "No available Cloud connection to" << host->name();
}
if (m_transportCandidates.isEmpty()) {
m_connectionStatus = ConnectionStatusNoBearerAvailable;
} else {
m_connectionStatus = ConnectionStatusConnecting;
}
emit connectionStatusChanged();
}
bool NymeaConnection::connectInternal(Connection *connection)
@ -539,10 +550,36 @@ bool NymeaConnection::connectInternal(Connection *connection)
}
m_transportCandidates.insert(newTransport, connection);
qDebug() << "Connecting to:" << connection->url();
qDebug() << "Connecting to:" << connection->url() << newTransport << m_transportCandidates.value(newTransport);
return newTransport->connect(connection->url());
}
NymeaConnection::BearerType NymeaConnection::qBearerTypeToNymeaBearerType(QNetworkConfiguration::BearerType type) const
{
switch (type) {
case QNetworkConfiguration::BearerUnknown:
return BearerTypeAll;
case QNetworkConfiguration::BearerEthernet:
return BearerTypeEthernet;
case QNetworkConfiguration::BearerWLAN:
return BearerTypeWiFi;
case QNetworkConfiguration::Bearer2G:
case QNetworkConfiguration::BearerCDMA2000:
case QNetworkConfiguration::BearerWCDMA:
case QNetworkConfiguration::BearerHSPA:
case QNetworkConfiguration::BearerWiMAX:
case QNetworkConfiguration::BearerEVDO:
case QNetworkConfiguration::BearerLTE:
case QNetworkConfiguration::Bearer3G:
case QNetworkConfiguration::Bearer4G:
return BearerTypeMobileData;
case QNetworkConfiguration::BearerBluetooth:
// Note: Do not confuse this with the Bluetooth transport... For Qt, this means IP over BT, not RFCOMM as we do it.
return BearerTypeNone;
}
return BearerTypeAll;
}
void NymeaConnection::disconnect()
{
setCurrentHost(nullptr);

View File

@ -20,10 +20,22 @@ class NymeaConnection : public QObject
Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged)
Q_PROPERTY(NymeaHost* currentHost READ currentHost WRITE setCurrentHost NOTIFY currentHostChanged)
Q_PROPERTY(Connection* currentConnection READ currentConnection NOTIFY currentConnectionChanged)
Q_PROPERTY(Connection::BearerTypes availableBearerTypes READ availableBearerTypes NOTIFY availableBearerTypesChanged)
Q_PROPERTY(NymeaConnection::BearerTypes availableBearerTypes READ availableBearerTypes NOTIFY availableBearerTypesChanged)
Q_PROPERTY(ConnectionStatus connectionStatus READ connectionStatus NOTIFY connectionStatusChanged)
public:
enum BearerType {
BearerTypeNone = 0x0,
BearerTypeEthernet = 0x1,
BearerTypeWiFi = 0x2,
BearerTypeMobileData = 0x4,
BearerTypeBluetooth = 0x8,
BearerTypeAll = 0xF
};
Q_ENUM(BearerType)
Q_DECLARE_FLAGS(BearerTypes, BearerType)
Q_FLAG(BearerTypes)
enum ConnectionStatus {
ConnectionStatusUnconnected,
ConnectionStatusConnecting,
@ -48,7 +60,7 @@ public:
Q_INVOKABLE void acceptCertificate(const QString &url, const QByteArray &pem);
Q_INVOKABLE bool isTrusted(const QString &url);
Connection::BearerTypes availableBearerTypes() const;
NymeaConnection::BearerTypes availableBearerTypes() const;
bool connected();
ConnectionStatus connectionStatus() const;
@ -84,12 +96,12 @@ private:
void connectInternal(NymeaHost *host);
bool connectInternal(Connection *connection);
Connection::BearerType qBearerTypeToNymeaBearerType(QNetworkConfiguration::BearerType type) const;
NymeaConnection::BearerType qBearerTypeToNymeaBearerType(QNetworkConfiguration::BearerType type) const;
private:
ConnectionStatus m_connectionStatus = ConnectionStatusUnconnected;
QNetworkConfigurationManager *m_networkConfigManager = nullptr;
Connection::BearerTypes m_availableBearerTypes = Connection::BearerTypeNone;
NymeaConnection::BearerTypes m_availableBearerTypes = BearerTypeNone;
QHash<QString, NymeaTransportInterfaceFactory*> m_transportFactories;
QHash<NymeaTransportInterface*, Connection*> m_transportCandidates;

View File

@ -37,6 +37,11 @@ NymeaHost::NymeaHost(QObject *parent):
});
}
NymeaHost::~NymeaHost()
{
qDebug() << "Deleting host:" << this << m_name;
}
QUuid NymeaHost::uuid() const
{
return m_uuid;
@ -84,6 +89,11 @@ Connections::Connections(QObject *parent):
}
Connections::~Connections()
{
qDebug() << "Deleting connections" << this;
}
int Connections::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
@ -172,7 +182,7 @@ Connection *Connections::bestMatch(Connection::BearerTypes bearerTypes) const
{
Connection *best = nullptr;
foreach (Connection *c, m_connections) {
// qDebug() << "have connection:" << bearerTypes << c->url() << bearerTypes.testFlag(c->bearerType());
qDebug() << "have connection:" << bearerTypes << c->url() << c->bearerType() << bearerTypes.testFlag(c->bearerType());
if ((bearerTypes & c->bearerType()) == Connection::BearerTypeNone) {
continue;
}
@ -208,6 +218,11 @@ Connection::Connection(const QUrl &url, Connection::BearerType bearerType, bool
}
Connection::~Connection()
{
qDebug() << "Deleting Connection" << this << parent() << parent()->parent();
}
QUrl Connection::url() const
{
return m_url;
@ -250,16 +265,16 @@ int Connection::priority() const
}
switch(m_bearerType) {
case BearerTypeEthernet:
case BearerTypeLan:
prio += 400;
break;
case BearerTypeWifi:
case BearerTypeWan:
prio += 300;
break;
case BearerTypeBluetooth:
case BearerTypeCloud:
prio += 200;
break;
case BearerTypeCloud:
case BearerTypeBluetooth:
prio += 100;
break;
default:

View File

@ -41,10 +41,10 @@ class Connection: public QObject {
public:
enum BearerType {
BearerTypeNone = 0x00,
BearerTypeWifi = 0x01,
BearerTypeEthernet = 0x02,
BearerTypeBluetooth = 0x04,
BearerTypeCloud = 0x08,
BearerTypeLan = 0x01,
BearerTypeWan = 0x02,
BearerTypeCloud = 0x04,
BearerTypeBluetooth = 0x08,
BearerTypeUnknown = 0xFF,
BearerTypeAll = 0xFF
};
@ -52,6 +52,7 @@ public:
Q_DECLARE_FLAGS(BearerTypes, BearerType)
Connection(const QUrl &url, BearerType bearerType, bool secure, const QString &displayName, QObject *parent = nullptr);
~Connection();
QUrl url() const;
BearerType bearerType() const;
@ -87,6 +88,7 @@ public:
};
Q_ENUM(Roles)
Connections(QObject* parent = nullptr);
~Connections() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
@ -121,6 +123,7 @@ class NymeaHost: public QObject
public:
explicit NymeaHost(QObject *parent = nullptr);
~NymeaHost();
QUuid uuid() const;
void setUuid(const QUuid &uuid);

View File

@ -84,11 +84,27 @@ void NymeaHosts::removeHost(NymeaHost *host)
emit countChanged();
}
NymeaHost *NymeaHosts::createCloudHost(const QString &name, const QUrl &url)
{
return createHost(name, url, Connection::BearerTypeCloud);
}
NymeaHost *NymeaHosts::createLanHost(const QString &name, const QUrl &url)
{
return createHost(name, url, Connection::BearerTypeLan);
}
NymeaHost *NymeaHosts::createWanHost(const QString &name, const QUrl &url)
{
return createHost(name, url, Connection::BearerTypeWan);
}
NymeaHost *NymeaHosts::createHost(const QString &name, const QUrl &url, Connection::BearerType bearerType)
{
NymeaHost *host = new NymeaHost(this);
host->setName(name);
Connection *connection = new Connection(url, bearerType, false, url.toString(), host);
connection->setOnline(true);
host->connections()->addConnection(connection);
addHost(host);
return host;
@ -208,16 +224,25 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
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())) {
switch (host->connections()->get(i)->bearerType()) {
case Connection::BearerTypeLan:
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
break;
case Connection::BearerTypeWan:
case Connection::BearerTypeCloud:
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeEthernet);
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeWiFi);
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeMobileData);
break;
case Connection::BearerTypeBluetooth:
hasReachableConnection |= m_nymeaConnection->availableBearerTypes().testFlag(NymeaConnection::BearerTypeBluetooth);
break;
case Connection::BearerTypeUnknown:
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;
}
case Connection::BearerTypeNone:
break;
}
}
if (!hasReachableConnection) {

View File

@ -49,7 +49,10 @@ public:
void addHost(NymeaHost *host);
void removeHost(NymeaHost *host);
Q_INVOKABLE NymeaHost* createHost(const QString &name, const QUrl &url, Connection::BearerType bearerType);
Q_INVOKABLE NymeaHost* createLanHost(const QString &name, const QUrl &url);
Q_INVOKABLE NymeaHost* createWanHost(const QString &name, const QUrl &url);
Q_INVOKABLE NymeaHost* createCloudHost(const QString &name, const QUrl &url);
NymeaHost* createHost(const QString &name, const QUrl &url, Connection::BearerType bearerType);
Q_INVOKABLE NymeaHost *get(int index) const;
Q_INVOKABLE NymeaHost *find(const QUuid &uuid);

View File

@ -149,8 +149,6 @@ void DeviceManager::getVendorsResponse(const QVariantMap &params)
}
}
qDebug() << "start getting deviceClass at" << QDateTime::currentDateTime();
m_jsonClient->sendCommand("Devices.GetSupportedDevices", this, "getSupportedDevicesResponse");
}

View File

@ -98,7 +98,7 @@ Item {
}
Binding {
target: discovey
target: _discovey
property: "discovering"
when: engine.connection.currentHost === null
value: true

View File

@ -178,5 +178,4 @@ Page {
}
}
}
}

View File

@ -60,7 +60,7 @@ Page {
}
onClicked: {
if (index === 2) {
var host = discovery.nymeaHosts.createHost("Demo server", "nymea://nymea.nymea.io:2222", Connection.BearerTypeCloud)
var host = discovery.nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
engine.connection.connect(host)
} else {
pageStack.push(model.get(index).page, {nymeaDiscovery: discovery});
@ -144,10 +144,12 @@ Page {
iconName: {
switch (nymeaHost.connections.get(defaultConnectionIndex).bearerType) {
case Connection.BearerTypeWifi:
case Connection.BearerTypeLan:
case Connection.BearerTypeWan:
if (engine.connection.availableBearerTypes & NymeaConnection.BearerTypeEthernet != NymeaConnection.BearerTypeNone) {
return "../images/network-wired-symbolic.svg"
}
return "../images/network-wifi-symbolic.svg";
case Connection.BearerTypeEthernet:
return "../images/network-wired-symbolic.svg"
case Connection.BearerTypeBluetooth:
return "../images/bluetooth.svg";
case Connection.BearerTypeCloud:
@ -163,7 +165,7 @@ Page {
progressive: false
property bool isSecure: nymeaHost.connections.get(defaultConnectionIndex).secure
property bool isTrusted: engine.connection.isTrusted(nymeaHostDelegate.nymeaHost.connections.get(defaultConnectionIndex).url)
property bool isOnline: nymeaHost.connections.get(defaultConnectionIndex).online
property bool isOnline: nymeaHost.connections.get(defaultConnectionIndex).bearerType !== Connection.BearerTypeWan ? nymeaHost.connections.get(defaultConnectionIndex).online : true
tertiaryIconName: isSecure ? "../images/network-secure.svg" : ""
tertiaryIconColor: isTrusted ? app.accentColor : Material.foreground
secondaryIconName: !isOnline ? "../images/cloud-error.svg" : ""
@ -246,7 +248,7 @@ Page {
visible: discovery.nymeaHosts.count === 0
text: qsTr("Demo mode (online)")
onClicked: {
var host = nymeaHosts.createHost("Demo server", "nymea://nymea.nymea.io:2222", Connection.BearerTypeCloud)
var host = nymeaHosts.createWanHost("Demo server", "nymea://nymea.nymea.io:2222")
engine.connection.connect(host)
}
}
@ -363,10 +365,12 @@ Page {
prominentSubText: false
iconName: {
switch (model.bearerType) {
case Connection.BearerTypeWifi:
case Connection.BearerTypeLan:
case Connection.BearerTypeWan:
if (engine.connection.availableBearerTypes & NymeaConnection.BearerTypeEthernet != NymeaConnection.BearerTypeNone) {
return "../images/network-wired-symbolic.svg"
}
return "../images/network-wifi-symbolic.svg";
case Connection.BearerTypeEthernet:
return "../images/network-wired-symbolic.svg"
case Connection.BearerTypeBluetooth:
return "../images/bluetooth.svg";
case Connection.BearerTypeCloud:

View File

@ -96,7 +96,7 @@ Page {
}
print("Try to connect ", rpcUrl)
var host = discovery.nymeaHosts.createHost("Manual connection", rpcUrl, Connection.BearerTypeCloud);
var host = discovery.nymeaHosts.createLanHost("Manual connection", rpcUrl);
engine.connection.connect(host)
}
}