handle unknonw bearer types

This commit is contained in:
Michael Zanetti 2019-02-06 15:03:10 +01:00
parent 5f202789c4
commit 468bdbd4fe
3 changed files with 9 additions and 4 deletions

View File

@ -325,7 +325,11 @@ void NymeaConnection::updateActiveBearers()
QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active); QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active);
// qDebug() << "Network configuations:" << configs.count(); // qDebug() << "Network configuations:" << configs.count();
foreach (const QNetworkConfiguration &config, configs) { 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())); availableBearerTypes.setFlag(qBearerTypeToNymeaBearerType(config.bearerType()));
} }
// qDebug() << "Available bearers:" << availableBearerTypes; // qDebug() << "Available bearers:" << availableBearerTypes;
@ -368,8 +372,8 @@ Connection::BearerType NymeaConnection::qBearerTypeToNymeaBearerType(QNetworkCon
return Connection::BearerTypeCloud; return Connection::BearerTypeCloud;
case QNetworkConfiguration::BearerBluetooth: case QNetworkConfiguration::BearerBluetooth:
return Connection::BearerTypeBluetooth; return Connection::BearerTypeBluetooth;
default: case QNetworkConfiguration::BearerUnknown:
qWarning() << "Unhandled Bearer Type Family:" << type; return Connection::BearerTypeUnknown;
} }
return Connection::BearerTypeNone; return Connection::BearerTypeNone;
} }

View File

@ -45,6 +45,7 @@ public:
BearerTypeEthernet = 0x02, BearerTypeEthernet = 0x02,
BearerTypeBluetooth = 0x04, BearerTypeBluetooth = 0x04,
BearerTypeCloud = 0x08, BearerTypeCloud = 0x08,
BearerTypeUnknown = 0xFF,
BearerTypeAll = 0xFF BearerTypeAll = 0xFF
}; };
Q_ENUM(BearerType) Q_ENUM(BearerType)

View File

@ -206,7 +206,7 @@ bool NymeaHostsFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
if (m_nymeaConnection && !m_showUneachableBearers) { if (m_nymeaConnection && !m_showUneachableBearers) {
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(); 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())) { if (m_nymeaConnection->availableBearerTypes().testFlag(host->connections()->get(i)->bearerType())) {
hasReachableConnection = true; hasReachableConnection = true;
break; break;