From 468bdbd4feceb90e4cdae98f9b0b40d26e320be7 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Wed, 6 Feb 2019 15:03:10 +0100 Subject: [PATCH] handle unknonw bearer types --- libnymea-app-core/connection/nymeaconnection.cpp | 10 +++++++--- libnymea-app-core/connection/nymeahost.h | 1 + libnymea-app-core/connection/nymeahosts.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libnymea-app-core/connection/nymeaconnection.cpp b/libnymea-app-core/connection/nymeaconnection.cpp index f5a8fe2d..ed769e3b 100644 --- a/libnymea-app-core/connection/nymeaconnection.cpp +++ b/libnymea-app-core/connection/nymeaconnection.cpp @@ -325,7 +325,11 @@ void NymeaConnection::updateActiveBearers() QList 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(); + 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); + availableBearerTypes.setFlag(qBearerTypeToNymeaBearerType(config.bearerType())); } // qDebug() << "Available bearers:" << availableBearerTypes; @@ -368,8 +372,8 @@ Connection::BearerType NymeaConnection::qBearerTypeToNymeaBearerType(QNetworkCon return Connection::BearerTypeCloud; case QNetworkConfiguration::BearerBluetooth: return Connection::BearerTypeBluetooth; - default: - qWarning() << "Unhandled Bearer Type Family:" << type; + case QNetworkConfiguration::BearerUnknown: + return Connection::BearerTypeUnknown; } return Connection::BearerTypeNone; } diff --git a/libnymea-app-core/connection/nymeahost.h b/libnymea-app-core/connection/nymeahost.h index 52659e53..1f62a336 100644 --- a/libnymea-app-core/connection/nymeahost.h +++ b/libnymea-app-core/connection/nymeahost.h @@ -45,6 +45,7 @@ public: BearerTypeEthernet = 0x02, BearerTypeBluetooth = 0x04, BearerTypeCloud = 0x08, + BearerTypeUnknown = 0xFF, BearerTypeAll = 0xFF }; Q_ENUM(BearerType) diff --git a/libnymea-app-core/connection/nymeahosts.cpp b/libnymea-app-core/connection/nymeahosts.cpp index fa6b8e8b..b00f5e2d 100644 --- a/libnymea-app-core/connection/nymeahosts.cpp +++ b/libnymea-app-core/connection/nymeahosts.cpp @@ -206,7 +206,7 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s if (m_nymeaConnection && !m_showUneachableBearers) { 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(); + 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(); if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) { hasReachableConnection = true; break;