diff --git a/.gitmodules b/.gitmodules index 2be744c1..b06a1905 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "QtZeroConf"] path = QtZeroConf - url = https://github.com/jbagg/QtZeroConf.git + url = https://github.com/mzanetti/QtZeroConf.git [submodule "nymea-remoteproxy"] path = nymea-remoteproxy url = https://github.com/guh/nymea-remoteproxy.git diff --git a/QtZeroConf b/QtZeroConf index 31119114..2990b858 160000 --- a/QtZeroConf +++ b/QtZeroConf @@ -1 +1 @@ -Subproject commit 31119114cec29b890bc755bed0272a208b7130bf +Subproject commit 2990b858e6334fae4dd37a77c770336bd6e1b2d9 diff --git a/libnymea-app-core/connection/awsclient.cpp b/libnymea-app-core/connection/awsclient.cpp index dca966c2..3bdafe9d 100644 --- a/libnymea-app-core/connection/awsclient.cpp +++ b/libnymea-app-core/connection/awsclient.cpp @@ -642,13 +642,13 @@ void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId, payload.insert("mobileDeviceUuid", mobileDeviceId); QJsonDocument jsonDoc = QJsonDocument::fromVariant(payload); - qDebug() << "Registering push notification endpoint:"; - qDebug() << "POST" << url.toString(); - qDebug() << "HEADERS:"; - foreach (const QByteArray &hdr, request.rawHeaderList()) { - qDebug() << hdr << ":" << request.rawHeader(hdr); - } - qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact)); +// qDebug() << "Registering push notification endpoint:"; +// qDebug() << "POST" << url.toString(); +// qDebug() << "HEADERS:"; +// foreach (const QByteArray &hdr, request.rawHeaderList()) { +// qDebug() << hdr << ":" << request.rawHeader(hdr); +// } +// qDebug() << "Payload:" << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Compact)); QNetworkReply *reply = m_nam->post(request, jsonDoc.toJson(QJsonDocument::Compact)); connect(reply, &QNetworkReply::finished, this, [reply]() { @@ -658,7 +658,7 @@ void AWSClient::registerPushNotificationEndpoint(const QString ®istrationId, qWarning() << "Error registering push notification endpoint:" << reply->error() << reply->errorString() << qUtf8Printable(data); return; } - qDebug() << "Push notification endpoint registered" << data; +// qDebug() << "Push notification endpoint registered" << data; }); } @@ -887,7 +887,7 @@ void AWSClient::fetchDevices() m_callQueue.append(QueuedCall("fetchDevices")); return; } - qDebug() << "Fetching cloud devices"; +// qDebug() << "Fetching cloud devices"; QUrl url(QString("https://%1/users/devices").arg(m_configs.at(m_usedConfigIndex).apiEndpoint)); QNetworkRequest request(url); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); @@ -914,7 +914,7 @@ void AWSClient::fetchDevices() QString deviceId = entry.toMap().value("deviceId").toString(); QString name = entry.toMap().value("name").toString(); bool online = entry.toMap().value("online").toBool(); - qDebug() << "Have cloud device:" << deviceId << name << "online:" << online; +// qDebug() << "Have cloud device:" << deviceId << name << "online:" << online; AWSDevice *d = m_devices->getDevice(deviceId); if (!d) { diff --git a/libnymea-app-core/discovery/bluetoothservicediscovery.cpp b/libnymea-app-core/discovery/bluetoothservicediscovery.cpp index 4eccf798..39ebbfc2 100644 --- a/libnymea-app-core/discovery/bluetoothservicediscovery.cpp +++ b/libnymea-app-core/discovery/bluetoothservicediscovery.cpp @@ -45,7 +45,7 @@ void BluetoothServiceDiscovery::discover() if (m_discovering) return; - qDebug() << "BluetoothServiceDiscovery: Service scan started for service: " << m_nymeaServiceUuid.toString(); +// qDebug() << "BluetoothServiceDiscovery: Service scan started for service: " << m_nymeaServiceUuid.toString(); setDiscovering(true); m_serviceDiscovery->setUuidFilter(m_nymeaServiceUuid); @@ -116,7 +116,7 @@ void BluetoothServiceDiscovery::onServiceDiscovered(const QBluetoothServiceInfo void BluetoothServiceDiscovery::onServiceDiscoveryFinished() { - qDebug() << "BluetoothServiceDiscovery: Service discovery finished."; +// qDebug() << "BluetoothServiceDiscovery: Service discovery finished."; setDiscovering(false); foreach (const QBluetoothServiceInfo &serviceInfo, m_serviceDiscovery->discoveredServices()) { @@ -130,7 +130,7 @@ void BluetoothServiceDiscovery::onServiceDiscoveryFinished() return; } - qDebug() << "BluetoothServiceDiscovery: Restart service discovery"; +// qDebug() << "BluetoothServiceDiscovery: Restart service discovery"; discover(); } } diff --git a/libnymea-app-core/discovery/nymeadiscovery.cpp b/libnymea-app-core/discovery/nymeadiscovery.cpp index af141d43..261677e0 100644 --- a/libnymea-app-core/discovery/nymeadiscovery.cpp +++ b/libnymea-app-core/discovery/nymeadiscovery.cpp @@ -88,7 +88,6 @@ DiscoveryModel *NymeaDiscovery::discoveryModel() const void NymeaDiscovery::syncCloudDevices() { - qDebug() << "Cloud devices fetched"; for (int i = 0; i < Engine::instance()->awsClient()->awsDevices()->rowCount(); i++) { AWSDevice *d = Engine::instance()->awsClient()->awsDevices()->get(i); DiscoveryDevice *device = m_discoveryModel->find(d->id()); @@ -96,6 +95,7 @@ void NymeaDiscovery::syncCloudDevices() device = new DiscoveryDevice(); device->setUuid(d->id()); device->setName(d->name()); + qDebug() << "CloudDiscovery: Adding new host:" << device->name() << device->uuid().toString(); m_discoveryModel->addDevice(device); } QUrl url; @@ -104,6 +104,7 @@ void NymeaDiscovery::syncCloudDevices() Connection *conn = device->connections()->find(url); if (!conn) { conn = new Connection(url, Connection::BearerTypeCloud, true, d->id()); + qDebug() << "CloudDiscovery: Adding new connection to host:" << device->name() << conn->url().toString(); device->connections()->addConnection(conn); } conn->setOnline(d->online()); diff --git a/libnymea-app-core/discovery/zeroconfdiscovery.cpp b/libnymea-app-core/discovery/zeroconfdiscovery.cpp index fc649586..5617c430 100644 --- a/libnymea-app-core/discovery/zeroconfdiscovery.cpp +++ b/libnymea-app-core/discovery/zeroconfdiscovery.cpp @@ -9,24 +9,34 @@ ZeroconfDiscovery::ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *pa m_discoveryModel(discoveryModel) { #ifdef WITH_ZEROCONF + // NOTE: There seem to be too many issues in QtZeroConf and IPv6. + // See https://github.com/jbagg/QtZeroConf/issues/22 + // IPv6 resolving is disabled completely for android in avahicore.cpp for now + // Limiting this to IPv4 for now... + m_zeroconfJsonRPC = new QZeroConf(this); connect(m_zeroconfJsonRPC, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfJsonRPC, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfJsonRPC, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved); - m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp", QAbstractSocket::AnyIPProtocol); + m_zeroconfJsonRPC->startBrowser("_jsonrpc._tcp", QAbstractSocket::IPv4Protocol); qDebug() << "ZeroConf: Created service browser for _jsonrpc._tcp:" << m_zeroconfJsonRPC->browserExists(); m_zeroconfWebSocket = new QZeroConf(this); connect(m_zeroconfWebSocket, &QZeroConf::serviceAdded, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfWebSocket, &QZeroConf::serviceUpdated, this, &ZeroconfDiscovery::serviceEntryAdded); connect(m_zeroconfWebSocket, &QZeroConf::serviceRemoved, this, &ZeroconfDiscovery::serviceEntryRemoved); - m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::AnyIPProtocol); - qDebug() << "TeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists(); + m_zeroconfWebSocket->startBrowser("_ws._tcp", QAbstractSocket::IPv4Protocol); + qDebug() << "ZeroConf: Created service browser for _ws._tcp:" << m_zeroconfWebSocket->browserExists(); #else qDebug() << "Zeroconf support not compiled in. Zeroconf will not be available."; #endif } +ZeroconfDiscovery::~ZeroconfDiscovery() +{ + qDebug() << "ZeroConf: Shutting down service browsers"; +} + bool ZeroconfDiscovery::available() const { #ifdef WITH_ZEROCONF @@ -46,18 +56,21 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry) { if (!entry.name().startsWith("nymea")) { // Skip non-nymea services altogether + qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type(); return; } if (entry.ip().isNull() && entry.ipv6().isNull()) { // Skip entries that don't have an ip address at all for some reason + qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type(); return; } if (entry.ip().isNull() && entry.ipv6().toString().startsWith("fe80")) { // Skip link-local-IPv6-only results + qDebug() << "Skipping Avahi entry:" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type(); return; } -// qDebug() << "zeroconf service discovered" << entry << entry.ip() << entry.ipv6() << entry.txt() << entry.type(); + qDebug() << "zeroconf service discovered" << entry.type() << entry.name() << " IP:" << entry.ip() << "IPv6:" << entry.ipv6() << entry.txt(); QString uuid; bool sslEnabled = false; diff --git a/libnymea-app-core/discovery/zeroconfdiscovery.h b/libnymea-app-core/discovery/zeroconfdiscovery.h index 905d009a..39608c33 100644 --- a/libnymea-app-core/discovery/zeroconfdiscovery.h +++ b/libnymea-app-core/discovery/zeroconfdiscovery.h @@ -15,6 +15,7 @@ class ZeroconfDiscovery : public QObject public: explicit ZeroconfDiscovery(DiscoveryModel *discoveryModel, QObject *parent = nullptr); + ~ZeroconfDiscovery(); bool available() const; bool discovering() const; diff --git a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp index 2027b46d..b7fc0853 100644 --- a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp @@ -126,7 +126,7 @@ void BluetoothDiscovery::setDiscovering(bool discovering) void BluetoothDiscovery::onBluetoothHostModeChanged(const QBluetoothLocalDevice::HostMode &hostMode) { - qDebug() << "BluetoothDiscovery: host mode changed" << hostMode; +// qDebug() << "BluetoothDiscovery: host mode changed" << hostMode; switch (hostMode) { case QBluetoothLocalDevice::HostPoweredOff: setBluetoothEnabled(false); @@ -148,7 +148,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo BluetoothDeviceInfo *deviceInformation = new BluetoothDeviceInfo(deviceInfo); bool isLowEnergy = deviceInfo.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration; - qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : ""); +// qDebug() << "BluetoothDiscovery: [+]" << deviceInformation->name() << "(" << deviceInformation->address() << ")" << (isLowEnergy ? "LE" : ""); if (!isLowEnergy || deviceInformation->name().isEmpty()) { delete deviceInformation; @@ -158,7 +158,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo // Check if we already have added this device info foreach (BluetoothDeviceInfo *di, m_deviceInfos->deviceInfos()) { if (di->address() == deviceInformation->address()) { - qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added"; +// qWarning() << "BluetoothDiscover: device" << deviceInformation->name() << "(" << deviceInformation->address() << ") already added"; deviceInformation->deleteLater(); return; } @@ -169,7 +169,7 @@ void BluetoothDiscovery::deviceDiscovered(const QBluetoothDeviceInfo &deviceInfo void BluetoothDiscovery::discoveryFinished() { - qDebug() << "BluetoothDiscovery: Discovery finished"; +// qDebug() << "BluetoothDiscovery: Discovery finished"; if (m_enabled) { m_discoveryAgent->start(); } @@ -197,7 +197,7 @@ void BluetoothDiscovery::start() return; } - qDebug() << "BluetoothDiscovery: Start discovering."; +// qDebug() << "BluetoothDiscovery: Start discovering."; m_discoveryAgent->start(); setDiscovering(true); } @@ -209,7 +209,7 @@ void BluetoothDiscovery::stop() if (!m_discoveryAgent) return; - qDebug() << "BluetoothDiscovery: Stop discovering."; +// qDebug() << "BluetoothDiscovery: Stop discovering."; m_discoveryAgent->stop(); setDiscovering(false); } diff --git a/nymea-app/pushnotifications.cpp b/nymea-app/pushnotifications.cpp index 48e3d1f7..c02384c4 100644 --- a/nymea-app/pushnotifications.cpp +++ b/nymea-app/pushnotifications.cpp @@ -36,12 +36,8 @@ void PushNotifications::connectClient() m_client_pointer = this; - m_firebase_initializer.Initialize(m_firebaseApp, - nullptr, [](::firebase::App * fapp, void *) { - qDebug() << "Trying to initialize Firebase Messaging"; - return ::firebase::messaging::Initialize( - *fapp, - (::firebase::messaging::Listener *)m_client_pointer); + m_firebase_initializer.Initialize(m_firebaseApp, nullptr, [](::firebase::App * fapp, void *) { + return ::firebase::messaging::Initialize( *fapp, (::firebase::messaging::Listener *)m_client_pointer); }); while (m_firebase_initializer.InitializeLastResult().status() !=