diff --git a/libnymea-app-core/bluetoothinterface.cpp b/libnymea-app-core/bluetoothinterface.cpp index 3576c1eb..ee5a9092 100644 --- a/libnymea-app-core/bluetoothinterface.cpp +++ b/libnymea-app-core/bluetoothinterface.cpp @@ -1,92 +1,110 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2018 Simon Stuerz * + * * + * This file is part of nymea:app * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; If not, see * + * . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #include "bluetoothinterface.h" -#include -#include +#include +#include BluetoothInterface::BluetoothInterface(QObject *parent) : - NymeaInterface(parent), - m_socket(0), - m_discovery(new BluetoothDiscovery(this)) + NymeaInterface(parent) { - connect(m_discovery, &BluetoothDiscovery::serviceFound, this, &BluetoothInterface::onServiceFound); + m_socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); + + QObject::connect(m_socket, &QBluetoothSocket::connected, this, &BluetoothInterface::onConnected); + QObject::connect(m_socket, &QBluetoothSocket::disconnected, this, &BluetoothInterface::onDisconnected); + QObject::connect(m_socket, &QBluetoothSocket::readyRead, this, &BluetoothInterface::onDataReady); +} + +QStringList BluetoothInterface::supportedSchemes() const +{ + return {"rfcom"}; +} + +void BluetoothInterface::connect(const QUrl &url) +{ + if (url.scheme() != "rfcom") { + qWarning() << "BluetoothInterface: Cannot connect. Invalid scheme in url" << url.toString(); + return; + } + + QString macAddress = url.host(); + qDebug() << "Connecting to bluetooth server" << macAddress; + m_socket->connectToService(QBluetoothAddress(macAddress), QBluetoothUuid(QUuid("997936b5-d2cd-4c57-b41b-c6048320cd2b"))); +} + +void BluetoothInterface::disconnect() +{ + m_socket->close(); +} + +NymeaInterface::ConnectionState BluetoothInterface::connectionState() const +{ + switch (m_socket->state()) { + case QBluetoothSocket::ConnectedState: + return NymeaInterface::ConnectionStateConnected; + case QBluetoothSocket::ConnectingState: + case QBluetoothSocket::ServiceLookupState: + return NymeaInterface::ConnectionStateConnecting; + default: + return NymeaInterface::ConnectionStateDisconnected; + } } void BluetoothInterface::sendData(const QByteArray &data) { - if (m_socket) - m_socket->write(data + '\n'); -} - -void BluetoothInterface::sendRequest(const QVariantMap &request) -{ - sendData(QJsonDocument::fromVariant(request).toJson(QJsonDocument::Compact)); -} - -BluetoothDiscovery *BluetoothInterface::discovery() -{ - return m_discovery; -} - -void BluetoothInterface::enable() -{ - if (m_socket) - return; - - m_socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol); - - connect(m_socket, &QBluetoothSocket::readyRead, this, &BluetoothInterface::onDataReady); - connect(m_socket, &QBluetoothSocket::connected, this, &BluetoothInterface::onConnected); - connect(m_socket, &QBluetoothSocket::disconnected, this, &BluetoothInterface::onDisconnected); -} - -void BluetoothInterface::disable() -{ - delete m_socket; - m_socket = 0; + m_socket->write(data + '\n'); } void BluetoothInterface::onServiceFound(const QBluetoothServiceInfo &service) { m_service = service; - enable(); - if (m_socket->isOpen()) return; - qDebug() << "Connecting to service" << m_service.serviceName(); + qDebug() << "BluetoothInterface: Connecting to service" << m_service.serviceName(); m_socket->connectToService(m_service); } void BluetoothInterface::onConnected() { - qDebug() << "Bluetooth Interface: connected" << m_socket->peerName() << m_socket->peerAddress(); - setConnected(true); + qDebug() << "BluetoothInterface: connected" << m_socket->peerName() << m_socket->peerAddress(); + emit connected(); } void BluetoothInterface::onDisconnected() { - qDebug() << "Bluetooth Interface: disconnected"; - setConnected(false); + qDebug() << "BluetoothInterface: disconnected" << m_socket->peerName() << m_socket->peerAddress(); + emit disconnected(); } void BluetoothInterface::onDataReady() { - if (!m_socket) - return; - QByteArray message; while (m_socket->canReadLine()) { QByteArray dataLine = m_socket->readLine(); message.append(dataLine); if (dataLine.endsWith('\n')) { - QJsonParseError error; - QJsonDocument jsonDoc = QJsonDocument::fromJson(message, &error); - if (error.error != QJsonParseError::NoError) { - qWarning() << "Could not parse json data from guh" << message << error.errorString(); - return; - } - - emit dataReady(jsonDoc.toVariant().toMap()); + emit dataReady(message); message.clear(); } } diff --git a/libnymea-app-core/bluetoothinterface.h b/libnymea-app-core/bluetoothinterface.h index 5ae215b1..7d033eb1 100644 --- a/libnymea-app-core/bluetoothinterface.h +++ b/libnymea-app-core/bluetoothinterface.h @@ -1,3 +1,25 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * + * Copyright (C) 2018 Simon Stuerz * + * * + * This file is part of nymea:app * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; If not, see * + * . * + * * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + #ifndef BLUETOOTHINTERFACE_H #define BLUETOOTHINTERFACE_H @@ -5,40 +27,29 @@ #include #include "nymeainterface.h" -#include "discovery/bluetoothdiscovery.h" class BluetoothInterface : public NymeaInterface { Q_OBJECT - Q_PROPERTY(BluetoothDiscovery *discovery READ discovery CONSTANT) - public: - explicit BluetoothInterface(QObject *parent = 0); + explicit BluetoothInterface(QObject *parent = nullptr); + QStringList supportedSchemes() const override; + + void connect(const QUrl &url) override; + void disconnect() override; + ConnectionState connectionState() const override; void sendData(const QByteArray &data) override; - void sendRequest(const QVariantMap &request) override; - - BluetoothDiscovery *discovery(); private: - QBluetoothSocket *m_socket; + QBluetoothSocket *m_socket = nullptr; QBluetoothServiceInfo m_service; - BluetoothDiscovery *m_discovery; - -signals: - -public slots: - Q_INVOKABLE void enable() override; - Q_INVOKABLE void disable() override; - private slots: void onServiceFound(const QBluetoothServiceInfo &service); void onConnected(); void onDisconnected(); - void onDataReady(); - }; #endif // BLUETOOTHINTERFACE_H diff --git a/libnymea-app-core/deviceclasses.cpp b/libnymea-app-core/deviceclasses.cpp index 5fe31e31..f3ea24f6 100644 --- a/libnymea-app-core/deviceclasses.cpp +++ b/libnymea-app-core/deviceclasses.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/deviceclasses.h b/libnymea-app-core/deviceclasses.h index f3e9d6d0..742ac6f5 100644 --- a/libnymea-app-core/deviceclasses.h +++ b/libnymea-app-core/deviceclasses.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/deviceclassesproxy.cpp b/libnymea-app-core/deviceclassesproxy.cpp index d5b35802..58a9ab85 100644 --- a/libnymea-app-core/deviceclassesproxy.cpp +++ b/libnymea-app-core/deviceclassesproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/deviceclassesproxy.h b/libnymea-app-core/deviceclassesproxy.h index 558b21fc..f87498aa 100644 --- a/libnymea-app-core/deviceclassesproxy.h +++ b/libnymea-app-core/deviceclassesproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/devices.cpp b/libnymea-app-core/devices.cpp index e7056cc2..62adc069 100644 --- a/libnymea-app-core/devices.cpp +++ b/libnymea-app-core/devices.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/devices.h b/libnymea-app-core/devices.h index 9d11c49e..7d6b7c7d 100644 --- a/libnymea-app-core/devices.h +++ b/libnymea-app-core/devices.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/devicesproxy.cpp b/libnymea-app-core/devicesproxy.cpp index 77dbdce1..3599502b 100644 --- a/libnymea-app-core/devicesproxy.cpp +++ b/libnymea-app-core/devicesproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/devicesproxy.h b/libnymea-app-core/devicesproxy.h index fd9beab2..1e68e5a6 100644 --- a/libnymea-app-core/devicesproxy.h +++ b/libnymea-app-core/devicesproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/discovery/bluetoothservicediscovery.cpp b/libnymea-app-core/discovery/bluetoothservicediscovery.cpp new file mode 100644 index 00000000..f07684a9 --- /dev/null +++ b/libnymea-app-core/discovery/bluetoothservicediscovery.cpp @@ -0,0 +1,107 @@ +#include "bluetoothservicediscovery.h" + +#include "discoverymodel.h" + +BluetoothServiceDiscovery::BluetoothServiceDiscovery(DiscoveryModel *discoveryModel, QObject *parent) : + QObject(parent), + m_discoveryModel(discoveryModel) +{ + m_localDevice = new QBluetoothLocalDevice(this); + connect(m_localDevice, &QBluetoothLocalDevice::hostModeStateChanged, this, &BluetoothServiceDiscovery::onHostModeChanged); + + m_serviceDiscovery = new QBluetoothServiceDiscoveryAgent(m_localDevice->address()); + connect(m_serviceDiscovery, &QBluetoothServiceDiscoveryAgent::serviceDiscovered, this, &BluetoothServiceDiscovery::onServiceDiscovered); + connect(m_serviceDiscovery, &QBluetoothServiceDiscoveryAgent::finished, this, &BluetoothServiceDiscovery::onServiceDiscoveryFinished); +} + +bool BluetoothServiceDiscovery::discovering() const +{ + return m_discovering; +} + +bool BluetoothServiceDiscovery::available() const +{ + return m_available; +} + +void BluetoothServiceDiscovery::discover(const QBluetoothUuid &uuid) +{ + m_enabed = true; + if (m_discovering) + return; + + qDebug() << "BluetoothServiceDiscovery: Start scanning services"; + setDiscovering(true); + m_serviceDiscovery->setUuidFilter(uuid); + m_serviceDiscovery->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); +} + +void BluetoothServiceDiscovery::stopDiscovery() +{ + m_enabed = false; + setDiscovering(false); + m_deviceDiscovery->stop(); +} + +void BluetoothServiceDiscovery::setDiscovering(const bool &discovering) +{ + if (m_discovering == discovering) + return; + + m_discovering = discovering; + emit discoveringChanged(m_discovering); +} + +void BluetoothServiceDiscovery::onHostModeChanged(const QBluetoothLocalDevice::HostMode &mode) +{ + qDebug() << "BluetoothServiceDiscovery: Host mode changed" << mode; +} + +void BluetoothServiceDiscovery::onServiceDiscovered(const QBluetoothServiceInfo &serviceInfo) +{ + qDebug() << "BluetoothServiceDiscovery: Service [+]" << serviceInfo.device().name() << serviceInfo.serviceName() << serviceInfo.serviceDescription() << serviceInfo.serviceProvider(); + + qDebug() << "Discovered service on" + << serviceInfo.device().name() << serviceInfo.device().address().toString(); + qDebug() << "\tService name:" << serviceInfo.serviceName(); + qDebug() << "\tDescription:" + << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString(); + qDebug() << "\tProvider:" + << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString(); + qDebug() << "\tL2CAP protocol service multiplexer:" + << serviceInfo.protocolServiceMultiplexer(); + qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel(); + + if (serviceInfo.serviceClassUuids().isEmpty()) + return; + + if (serviceInfo.serviceClassUuids().first() == QBluetoothUuid(QUuid("997936b5-d2cd-4c57-b41b-c6048320cd2b"))) { + qDebug() << "Found nymea rfcom service!"; + + DiscoveryDevice* device = m_discoveryModel->find(serviceInfo.device().address()); + if (!device) { + device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeBluetooth, this); + qDebug() << "BluetoothServiceDiscovery: Adding new bluetooth host to model"; + device->setName(serviceInfo.device().name()); + device->setBluetoothAddress(serviceInfo.device().address()); + m_discoveryModel->addDevice(device); + } + } +} + +void BluetoothServiceDiscovery::onServiceDiscoveryFinished() +{ + qDebug() << "BluetoothServiceDiscovery: Service discovery finished."; + setDiscovering(false); + + foreach (const QBluetoothServiceInfo &serviceInfo, m_serviceDiscovery->discoveredServices()) { + onServiceDiscovered(serviceInfo); + } + + // If discover was called, but never stopDiscover, continue discovery + if (m_enabed) { + qDebug() << "BluetoothServiceDiscovery: Restart bluetooth discovery"; + m_serviceDiscovery->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); + + } +} diff --git a/libnymea-app-core/discovery/bluetoothservicediscovery.h b/libnymea-app-core/discovery/bluetoothservicediscovery.h new file mode 100644 index 00000000..567e697d --- /dev/null +++ b/libnymea-app-core/discovery/bluetoothservicediscovery.h @@ -0,0 +1,45 @@ +#ifndef BLUETOOTHSERVICEDISCOVERY_H +#define BLUETOOTHSERVICEDISCOVERY_H + +#include +#include +#include + +class DiscoveryModel; + +class BluetoothServiceDiscovery : public QObject +{ + Q_OBJECT +public: + explicit BluetoothServiceDiscovery(DiscoveryModel *discoveryModel, QObject *parent = nullptr); + + bool discovering() const; + bool available() const; + + Q_INVOKABLE void discover(const QBluetoothUuid &uuid); + Q_INVOKABLE void stopDiscovery(); + +private: + DiscoveryModel *m_discoveryModel = nullptr; + QBluetoothLocalDevice *m_localDevice = nullptr; + QBluetoothDeviceDiscoveryAgent *m_deviceDiscovery = nullptr; + QBluetoothServiceDiscoveryAgent *m_serviceDiscovery = nullptr; + + bool m_enabed = false; + bool m_discovering = false; + bool m_available = false; + + void setDiscovering(const bool &discovering); + +signals: + void discoveringChanged(bool discovering); + +private slots: + void onHostModeChanged(const QBluetoothLocalDevice::HostMode &mode); + + void onServiceDiscovered(const QBluetoothServiceInfo &serviceInfo); + void onServiceDiscoveryFinished(); + +}; + +#endif // BLUETOOTHSERVICEDISCOVERY_H diff --git a/libnymea-app-core/discovery/discoverydevice.cpp b/libnymea-app-core/discovery/discoverydevice.cpp index 27c011d9..e0c4e00a 100644 --- a/libnymea-app-core/discovery/discoverydevice.cpp +++ b/libnymea-app-core/discovery/discoverydevice.cpp @@ -22,11 +22,18 @@ #include -DiscoveryDevice::DiscoveryDevice(QObject *parent): QObject(parent) +DiscoveryDevice::DiscoveryDevice(DeviceType deviceType, QObject *parent): + QObject(parent), + m_deviceType(deviceType) { m_portConfigs = new PortConfigs(this); } +DiscoveryDevice::DeviceType DiscoveryDevice::deviceType() const +{ + return m_deviceType; +} + QUuid DiscoveryDevice::uuid() const { return m_uuid; @@ -55,6 +62,25 @@ void DiscoveryDevice::setHostAddress(const QHostAddress &hostAddress) } } +QBluetoothAddress DiscoveryDevice::bluetoothAddress() const +{ + return m_bluetoothAddress; +} + +QString DiscoveryDevice::bluetoothAddressString() const +{ + return m_bluetoothAddress.toString(); +} + +void DiscoveryDevice::setBluetoothAddress(const QBluetoothAddress &bluetoothAddress) +{ + if (m_bluetoothAddress == bluetoothAddress) + return; + + m_bluetoothAddress = bluetoothAddress; + emit bluetoothAddressChanged(); +} + QString DiscoveryDevice::name() const { return m_name; @@ -102,6 +128,11 @@ QString DiscoveryDevice::toUrl(int portConfigIndex) return ret; } +QString DiscoveryDevice::toUrl(const QString &hostAddress) +{ + return QString("rfcom://%1").arg(hostAddress); +} + PortConfigs::PortConfigs(QObject *parent): QAbstractListModel(parent) { @@ -147,6 +178,9 @@ void PortConfigs::insert(PortConfig *portConfig) PortConfig* PortConfigs::get(int index) const { + if (index < 0 || index >= m_portConfigs.count()) + return nullptr; + return m_portConfigs.at(index); } diff --git a/libnymea-app-core/discovery/discoverydevice.h b/libnymea-app-core/discovery/discoverydevice.h index 5cf98e29..66a27d41 100644 --- a/libnymea-app-core/discovery/discoverydevice.h +++ b/libnymea-app-core/discovery/discoverydevice.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -94,14 +95,24 @@ private: class DiscoveryDevice: public QObject { Q_OBJECT + Q_PROPERTY(DeviceType deviceType READ deviceType CONSTANT) Q_PROPERTY(QUuid uuid READ uuid CONSTANT) Q_PROPERTY(QString hostAddress READ hostAddressString NOTIFY hostAddressChanged) + Q_PROPERTY(QString bluetoothAddress READ bluetoothAddressString NOTIFY bluetoothAddressChanged) Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString version READ version NOTIFY versionChanged) Q_PROPERTY(PortConfigs* portConfigs READ portConfigs CONSTANT) public: - explicit DiscoveryDevice(QObject *parent = nullptr); + enum DeviceType { + DeviceTypeNetwork, + DeviceTypeBluetooth + }; + Q_ENUM(DeviceType) + + explicit DiscoveryDevice(DeviceType deviceType, QObject *parent = nullptr); + + DeviceType deviceType() const; QUuid uuid() const; void setUuid(const QUuid &uuid); @@ -110,6 +121,10 @@ public: QString hostAddressString() const; void setHostAddress(const QHostAddress &hostAddress); + QBluetoothAddress bluetoothAddress() const; + QString bluetoothAddressString() const; + void setBluetoothAddress(const QBluetoothAddress &bluetoothAddress); + QString name() const; void setName(const QString &name); @@ -119,15 +134,19 @@ public: PortConfigs *portConfigs() const; Q_INVOKABLE QString toUrl(int portConfigIndex); + Q_INVOKABLE QString toUrl(const QString &hostAddress); signals: void nameChanged(); void hostAddressChanged(); + void bluetoothAddressChanged(); void versionChanged(); private: + DeviceType m_deviceType = DeviceTypeNetwork; QUuid m_uuid; QHostAddress m_hostAddress; + QBluetoothAddress m_bluetoothAddress; QString m_name; QString m_version; PortConfigs *m_portConfigs = nullptr; diff --git a/libnymea-app-core/discovery/discoverymodel.cpp b/libnymea-app-core/discovery/discoverymodel.cpp index 0916052e..d295d826 100644 --- a/libnymea-app-core/discovery/discoverymodel.cpp +++ b/libnymea-app-core/discovery/discoverymodel.cpp @@ -38,12 +38,16 @@ QVariant DiscoveryModel::data(const QModelIndex &index, int role) const DiscoveryDevice *device = m_devices.at(index.row()); switch (role) { + case TypeRole: + return device->deviceType(); case UuidRole: return device->uuid(); case NameRole: return device->name(); case HostAddressRole: return device->hostAddress().toString(); + case BluetoothAddressRole: + return device->bluetoothAddressString(); // case WebSocketUrlRole: // return device.webSocketUrl(); // case PortRole: @@ -86,6 +90,17 @@ DiscoveryDevice *DiscoveryModel::find(const QUuid &uuid) return nullptr; } +DiscoveryDevice *DiscoveryModel::find(const QBluetoothAddress &bluetoothAddress) +{ + foreach (DiscoveryDevice *device, m_devices) { + if (device->bluetoothAddress() == bluetoothAddress) { + return device; + } + } + + return nullptr; +} + void DiscoveryModel::clearModel() { beginResetModel(); @@ -97,9 +112,11 @@ void DiscoveryModel::clearModel() QHash DiscoveryModel::roleNames() const { QHash roles; + roles[TypeRole] = "type"; roles[UuidRole] = "uuid"; roles[NameRole] = "name"; roles[HostAddressRole] = "hostAddress"; + roles[BluetoothAddressRole] = "bluetoothAddress"; roles[VersionRole] = "version"; return roles; } diff --git a/libnymea-app-core/discovery/discoverymodel.h b/libnymea-app-core/discovery/discoverymodel.h index 3f284a79..badcfc31 100644 --- a/libnymea-app-core/discovery/discoverymodel.h +++ b/libnymea-app-core/discovery/discoverymodel.h @@ -32,9 +32,11 @@ class DiscoveryModel : public QAbstractListModel Q_PROPERTY(int count READ rowCount NOTIFY countChanged) public: enum DeviceRole { + TypeRole, UuidRole, NameRole, HostAddressRole, + BluetoothAddressRole, VersionRole }; Q_ENUM(DeviceRole) @@ -48,6 +50,7 @@ public: Q_INVOKABLE DiscoveryDevice* get(int index) const; Q_INVOKABLE DiscoveryDevice* find(const QUuid &uuid); + Q_INVOKABLE DiscoveryDevice* find(const QBluetoothAddress &bluetoothAddress); void clearModel(); diff --git a/libnymea-app-core/discovery/nymeadiscovery.cpp b/libnymea-app-core/discovery/nymeadiscovery.cpp index 3167be5e..49bae5d5 100644 --- a/libnymea-app-core/discovery/nymeadiscovery.cpp +++ b/libnymea-app-core/discovery/nymeadiscovery.cpp @@ -2,6 +2,7 @@ #include "upnpdiscovery.h" #include "zeroconfdiscovery.h" +#include "bluetoothservicediscovery.h" NymeaDiscovery::NymeaDiscovery(QObject *parent) : QObject(parent) { @@ -9,6 +10,7 @@ NymeaDiscovery::NymeaDiscovery(QObject *parent) : QObject(parent) m_upnp = new UpnpDiscovery(m_discoveryModel, this); m_zeroConf = new ZeroconfDiscovery(m_discoveryModel, this); + m_bluetooth = new BluetoothServiceDiscovery(m_discoveryModel, this); } bool NymeaDiscovery::discovering() const @@ -18,16 +20,20 @@ bool NymeaDiscovery::discovering() const void NymeaDiscovery::setDiscovering(bool discovering) { - if (m_discovering != discovering) { - m_discovering = discovering; - // For zeroconf we'll ignore it as zeroconf doesn't do active discovery but just listens for changes in the net all the time - if (discovering) { - m_upnp->discover(); - } else { - m_upnp->stopDiscovery(); - } - emit discoveringChanged(); + if (m_discovering == discovering) + return; + + m_discovering = discovering; + // For zeroconf we'll ignore it as zeroconf doesn't do active discovery but just listens for changes in the net all the time + if (discovering) { + //m_upnp->discover(); + // Note: this is the nymea uuid + m_bluetooth->discover(QBluetoothUuid(QUuid("997936b5-d2cd-4c57-b41b-c6048320cd2b"))); + } else { + m_upnp->stopDiscovery(); + m_bluetooth->stopDiscovery(); } + emit discoveringChanged(); } DiscoveryModel *NymeaDiscovery::discoveryModel() const diff --git a/libnymea-app-core/discovery/nymeadiscovery.h b/libnymea-app-core/discovery/nymeadiscovery.h index 63a22188..1a4850e3 100644 --- a/libnymea-app-core/discovery/nymeadiscovery.h +++ b/libnymea-app-core/discovery/nymeadiscovery.h @@ -6,6 +6,7 @@ class DiscoveryModel; class UpnpDiscovery; class ZeroconfDiscovery; +class BluetoothServiceDiscovery; class NymeaDiscovery : public QObject { @@ -30,6 +31,8 @@ private: UpnpDiscovery *m_upnp = nullptr; ZeroconfDiscovery *m_zeroConf = nullptr; + BluetoothServiceDiscovery *m_bluetooth = nullptr; + }; #endif // NYMEADISCOVERY_H diff --git a/libnymea-app-core/discovery/upnpdiscovery.cpp b/libnymea-app-core/discovery/upnpdiscovery.cpp index 8499167b..4fb9249e 100644 --- a/libnymea-app-core/discovery/upnpdiscovery.cpp +++ b/libnymea-app-core/discovery/upnpdiscovery.cpp @@ -264,7 +264,7 @@ void UpnpDiscovery::networkReplyFinished(QNetworkReply *reply) DiscoveryDevice* device = m_discoveryModel->find(uuid); if (!device) { - device = new DiscoveryDevice(m_discoveryModel); + device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeNetwork, m_discoveryModel); device->setUuid(uuid); qDebug() << "Adding new host to model"; m_discoveryModel->addDevice(device); diff --git a/libnymea-app-core/discovery/zeroconfdiscovery.cpp b/libnymea-app-core/discovery/zeroconfdiscovery.cpp index 1b808e60..023cb9ca 100644 --- a/libnymea-app-core/discovery/zeroconfdiscovery.cpp +++ b/libnymea-app-core/discovery/zeroconfdiscovery.cpp @@ -70,7 +70,7 @@ void ZeroconfDiscovery::serviceEntryAdded(const QZeroConfService &entry) DiscoveryDevice* device = m_discoveryModel->find(uuid); if (!device) { - device = new DiscoveryDevice(m_discoveryModel); + device = new DiscoveryDevice(DiscoveryDevice::DeviceTypeNetwork, m_discoveryModel); device->setUuid(uuid); // qDebug() << "Adding new host to model"; m_discoveryModel->addDevice(device); diff --git a/libnymea-app-core/libnymea-app-core.pro b/libnymea-app-core/libnymea-app-core.pro index bfc94288..2f4f433a 100644 --- a/libnymea-app-core/libnymea-app-core.pro +++ b/libnymea-app-core/libnymea-app-core.pro @@ -67,7 +67,9 @@ SOURCES += \ ruletemplates/eventdescriptortemplate.cpp \ ruletemplates/ruleactiontemplate.cpp \ ruletemplates/stateevaluatortemplate.cpp \ - ruletemplates/statedescriptortemplate.cpp + ruletemplates/statedescriptortemplate.cpp \ + bluetoothinterface.cpp \ + discovery/bluetoothservicediscovery.cpp \ HEADERS += \ engine.h \ @@ -120,7 +122,9 @@ HEADERS += \ ruletemplates/eventdescriptortemplate.h \ ruletemplates/ruleactiontemplate.h \ ruletemplates/stateevaluatortemplate.h \ - ruletemplates/statedescriptortemplate.h + ruletemplates/statedescriptortemplate.h \ + bluetoothinterface.h \ + discovery/bluetoothservicediscovery.h \ unix { target.path = /usr/lib diff --git a/libnymea-app-core/nymeainterface.cpp b/libnymea-app-core/nymeainterface.cpp index 5fd4de15..f9a809d1 100644 --- a/libnymea-app-core/nymeainterface.cpp +++ b/libnymea-app-core/nymeainterface.cpp @@ -2,19 +2,21 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app. * + * This file is part of nymea:app. * * * - * nymea:app is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, version 3 of the License. * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * * * - * nymea:app is distributed in the hope that it will be useful, * + * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * * * - * You should have received a copy of the GNU General Public License * - * along with nymea:app. If not, see . * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; If not, see * + * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/libnymea-app-core/nymeainterface.h b/libnymea-app-core/nymeainterface.h index f3d9ffa8..7a9ade19 100644 --- a/libnymea-app-core/nymeainterface.h +++ b/libnymea-app-core/nymeainterface.h @@ -1,20 +1,22 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright (C) 2017 Simon Stuerz * + * Copyright (C) 2017 - 2018 Simon Stuerz * * * - * This file is part of nymea:app. * + * This file is part of nymea:app. * * * - * nymea:app is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, version 3 of the License. * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 2.1 of the License, or (at your option) any later version. * * * - * nymea:app is distributed in the hope that it will be useful, * + * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * * * - * You should have received a copy of the GNU General Public License * - * along with nymea:app. If not, see . * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; If not, see * + * . * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -44,7 +46,7 @@ public: virtual void disconnect() = 0; virtual ConnectionState connectionState() const = 0; virtual void sendData(const QByteArray &data) = 0; - virtual void ignoreSslErrors(const QList &errors) = 0; + virtual void ignoreSslErrors(const QList &errors) { Q_UNUSED(errors) } signals: void connected(); diff --git a/libnymea-app-core/pluginsproxy.cpp b/libnymea-app-core/pluginsproxy.cpp index d63a911c..ac33b937 100644 --- a/libnymea-app-core/pluginsproxy.cpp +++ b/libnymea-app-core/pluginsproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/pluginsproxy.h b/libnymea-app-core/pluginsproxy.h index ad0df47d..ddb609ff 100644 --- a/libnymea-app-core/pluginsproxy.h +++ b/libnymea-app-core/pluginsproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/vendorsproxy.cpp b/libnymea-app-core/vendorsproxy.cpp index c391c4e3..a4ce4568 100644 --- a/libnymea-app-core/vendorsproxy.cpp +++ b/libnymea-app-core/vendorsproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/vendorsproxy.h b/libnymea-app-core/vendorsproxy.h index e2acc941..d86a62c9 100644 --- a/libnymea-app-core/vendorsproxy.h +++ b/libnymea-app-core/vendorsproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdevice.cpp b/libnymea-app-core/wifisetup/bluetoothdevice.cpp index a2ba4039..763be3ee 100644 --- a/libnymea-app-core/wifisetup/bluetoothdevice.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdevice.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdevice.h b/libnymea-app-core/wifisetup/bluetoothdevice.h index 1a9b184f..46773b88 100644 --- a/libnymea-app-core/wifisetup/bluetoothdevice.h +++ b/libnymea-app-core/wifisetup/bluetoothdevice.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdeviceinfo.cpp b/libnymea-app-core/wifisetup/bluetoothdeviceinfo.cpp index 5bcaa26a..0f89cc1e 100644 --- a/libnymea-app-core/wifisetup/bluetoothdeviceinfo.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdeviceinfo.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdeviceinfo.h b/libnymea-app-core/wifisetup/bluetoothdeviceinfo.h index 75460f2d..6569f2e2 100644 --- a/libnymea-app-core/wifisetup/bluetoothdeviceinfo.h +++ b/libnymea-app-core/wifisetup/bluetoothdeviceinfo.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdeviceinfos.cpp b/libnymea-app-core/wifisetup/bluetoothdeviceinfos.cpp index e3b28452..08af3b46 100644 --- a/libnymea-app-core/wifisetup/bluetoothdeviceinfos.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdeviceinfos.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdeviceinfos.h b/libnymea-app-core/wifisetup/bluetoothdeviceinfos.h index 9e47fbfb..35cd2d9a 100644 --- a/libnymea-app-core/wifisetup/bluetoothdeviceinfos.h +++ b/libnymea-app-core/wifisetup/bluetoothdeviceinfos.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp index d7719bce..02037848 100644 --- a/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp +++ b/libnymea-app-core/wifisetup/bluetoothdiscovery.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/bluetoothdiscovery.h b/libnymea-app-core/wifisetup/bluetoothdiscovery.h index 65401797..756778d3 100644 --- a/libnymea-app-core/wifisetup/bluetoothdiscovery.h +++ b/libnymea-app-core/wifisetup/bluetoothdiscovery.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/networkmanagercontroler.cpp b/libnymea-app-core/wifisetup/networkmanagercontroler.cpp index a5f02e1e..cbe2dc1d 100644 --- a/libnymea-app-core/wifisetup/networkmanagercontroler.cpp +++ b/libnymea-app-core/wifisetup/networkmanagercontroler.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/networkmanagercontroler.h b/libnymea-app-core/wifisetup/networkmanagercontroler.h index d8a0cfc6..b3921cf5 100644 --- a/libnymea-app-core/wifisetup/networkmanagercontroler.h +++ b/libnymea-app-core/wifisetup/networkmanagercontroler.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspoint.cpp b/libnymea-app-core/wifisetup/wirelessaccesspoint.cpp index c6153486..365865d9 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspoint.cpp +++ b/libnymea-app-core/wifisetup/wirelessaccesspoint.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspoint.h b/libnymea-app-core/wifisetup/wirelessaccesspoint.h index 9fc5ea8a..ab24b11f 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspoint.h +++ b/libnymea-app-core/wifisetup/wirelessaccesspoint.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspoints.cpp b/libnymea-app-core/wifisetup/wirelessaccesspoints.cpp index 1c8fd3f6..cc245e93 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspoints.cpp +++ b/libnymea-app-core/wifisetup/wirelessaccesspoints.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspoints.h b/libnymea-app-core/wifisetup/wirelessaccesspoints.h index 9f9f1465..2d6848ca 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspoints.h +++ b/libnymea-app-core/wifisetup/wirelessaccesspoints.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.cpp b/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.cpp index 18279181..ea625403 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.cpp +++ b/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.h b/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.h index 2493fdb1..f8dafb0a 100644 --- a/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.h +++ b/libnymea-app-core/wifisetup/wirelessaccesspointsproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelesssetupmanager.cpp b/libnymea-app-core/wifisetup/wirelesssetupmanager.cpp index 5277b06a..a3cf9de9 100644 --- a/libnymea-app-core/wifisetup/wirelesssetupmanager.cpp +++ b/libnymea-app-core/wifisetup/wirelesssetupmanager.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-app-core/wifisetup/wirelesssetupmanager.h b/libnymea-app-core/wifisetup/wirelesssetupmanager.h index a3c223a1..51bf5486 100644 --- a/libnymea-app-core/wifisetup/wirelesssetupmanager.h +++ b/libnymea-app-core/wifisetup/wirelesssetupmanager.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2018 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/actiontype.cpp b/libnymea-common/types/actiontype.cpp index 88dbea5c..ca1229d8 100644 --- a/libnymea-common/types/actiontype.cpp +++ b/libnymea-common/types/actiontype.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/actiontype.h b/libnymea-common/types/actiontype.h index 8f1345a4..bf3cfa34 100644 --- a/libnymea-common/types/actiontype.h +++ b/libnymea-common/types/actiontype.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/actiontypes.cpp b/libnymea-common/types/actiontypes.cpp index f2aa43a3..ecac57b5 100644 --- a/libnymea-common/types/actiontypes.cpp +++ b/libnymea-common/types/actiontypes.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/actiontypes.h b/libnymea-common/types/actiontypes.h index 04aaffb2..081ab1bd 100644 --- a/libnymea-common/types/actiontypes.h +++ b/libnymea-common/types/actiontypes.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/device.cpp b/libnymea-common/types/device.cpp index ec3ac241..4d85e68e 100644 --- a/libnymea-common/types/device.cpp +++ b/libnymea-common/types/device.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/device.h b/libnymea-common/types/device.h index c5a2594a..a5f25a82 100644 --- a/libnymea-common/types/device.h +++ b/libnymea-common/types/device.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/deviceclass.cpp b/libnymea-common/types/deviceclass.cpp index 2b220052..b078740a 100644 --- a/libnymea-common/types/deviceclass.cpp +++ b/libnymea-common/types/deviceclass.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/deviceclass.h b/libnymea-common/types/deviceclass.h index 82fef48d..3e6db9c3 100644 --- a/libnymea-common/types/deviceclass.h +++ b/libnymea-common/types/deviceclass.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/eventtype.cpp b/libnymea-common/types/eventtype.cpp index 834e1ec2..11e6241a 100644 --- a/libnymea-common/types/eventtype.cpp +++ b/libnymea-common/types/eventtype.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/eventtype.h b/libnymea-common/types/eventtype.h index 98e791c2..498e0ffa 100644 --- a/libnymea-common/types/eventtype.h +++ b/libnymea-common/types/eventtype.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/eventtypes.cpp b/libnymea-common/types/eventtypes.cpp index af31f39c..368d6e04 100644 --- a/libnymea-common/types/eventtypes.cpp +++ b/libnymea-common/types/eventtypes.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/eventtypes.h b/libnymea-common/types/eventtypes.h index 3e474912..1f81857c 100644 --- a/libnymea-common/types/eventtypes.h +++ b/libnymea-common/types/eventtypes.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/param.cpp b/libnymea-common/types/param.cpp index 4fc2ecca..963cbebc 100644 --- a/libnymea-common/types/param.cpp +++ b/libnymea-common/types/param.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/param.h b/libnymea-common/types/param.h index e747e2af..4e6af188 100644 --- a/libnymea-common/types/param.h +++ b/libnymea-common/types/param.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/params.cpp b/libnymea-common/types/params.cpp index 5648ff29..f4279c39 100644 --- a/libnymea-common/types/params.cpp +++ b/libnymea-common/types/params.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/params.h b/libnymea-common/types/params.h index bb514ef6..27da733f 100644 --- a/libnymea-common/types/params.h +++ b/libnymea-common/types/params.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/paramtype.cpp b/libnymea-common/types/paramtype.cpp index b2fcc5aa..0476d8f1 100644 --- a/libnymea-common/types/paramtype.cpp +++ b/libnymea-common/types/paramtype.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/paramtype.h b/libnymea-common/types/paramtype.h index c7007c4e..aaaf56fc 100644 --- a/libnymea-common/types/paramtype.h +++ b/libnymea-common/types/paramtype.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/paramtypes.cpp b/libnymea-common/types/paramtypes.cpp index ba99430d..ec5e757a 100644 --- a/libnymea-common/types/paramtypes.cpp +++ b/libnymea-common/types/paramtypes.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/paramtypes.h b/libnymea-common/types/paramtypes.h index a28abeb1..0802b404 100644 --- a/libnymea-common/types/paramtypes.h +++ b/libnymea-common/types/paramtypes.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/plugin.cpp b/libnymea-common/types/plugin.cpp index 76c097c5..2978db58 100644 --- a/libnymea-common/types/plugin.cpp +++ b/libnymea-common/types/plugin.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/plugin.h b/libnymea-common/types/plugin.h index dc03774d..df53002d 100644 --- a/libnymea-common/types/plugin.h +++ b/libnymea-common/types/plugin.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/plugins.cpp b/libnymea-common/types/plugins.cpp index 657d382e..b00b06b5 100644 --- a/libnymea-common/types/plugins.cpp +++ b/libnymea-common/types/plugins.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/plugins.h b/libnymea-common/types/plugins.h index 007417e1..6aeccfb7 100644 --- a/libnymea-common/types/plugins.h +++ b/libnymea-common/types/plugins.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/state.cpp b/libnymea-common/types/state.cpp index 2b437bb6..02a5b3d0 100644 --- a/libnymea-common/types/state.cpp +++ b/libnymea-common/types/state.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/state.h b/libnymea-common/types/state.h index 4fa66aba..6884cf2d 100644 --- a/libnymea-common/types/state.h +++ b/libnymea-common/types/state.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/states.cpp b/libnymea-common/types/states.cpp index b255ca9f..e49f3a0e 100644 --- a/libnymea-common/types/states.cpp +++ b/libnymea-common/types/states.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/states.h b/libnymea-common/types/states.h index 582f31af..51b7794b 100644 --- a/libnymea-common/types/states.h +++ b/libnymea-common/types/states.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statesproxy.cpp b/libnymea-common/types/statesproxy.cpp index c86bee24..7b3c7c8d 100644 --- a/libnymea-common/types/statesproxy.cpp +++ b/libnymea-common/types/statesproxy.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statesproxy.h b/libnymea-common/types/statesproxy.h index 769b6a15..311f1bb4 100644 --- a/libnymea-common/types/statesproxy.h +++ b/libnymea-common/types/statesproxy.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statetype.cpp b/libnymea-common/types/statetype.cpp index 99888e2e..493c543c 100644 --- a/libnymea-common/types/statetype.cpp +++ b/libnymea-common/types/statetype.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statetype.h b/libnymea-common/types/statetype.h index 85bdea34..7350546f 100644 --- a/libnymea-common/types/statetype.h +++ b/libnymea-common/types/statetype.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statetypes.cpp b/libnymea-common/types/statetypes.cpp index 0875d14f..b80fc9fe 100644 --- a/libnymea-common/types/statetypes.cpp +++ b/libnymea-common/types/statetypes.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/statetypes.h b/libnymea-common/types/statetypes.h index b890e046..f77aa8ed 100644 --- a/libnymea-common/types/statetypes.h +++ b/libnymea-common/types/statetypes.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/types.h b/libnymea-common/types/types.h index 3c651f57..fa168465 100644 --- a/libnymea-common/types/types.h +++ b/libnymea-common/types/types.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/vendor.cpp b/libnymea-common/types/vendor.cpp index 3a6a86d5..d3b16256 100644 --- a/libnymea-common/types/vendor.cpp +++ b/libnymea-common/types/vendor.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/vendor.h b/libnymea-common/types/vendor.h index f7c41fdb..b4f25b23 100644 --- a/libnymea-common/types/vendor.h +++ b/libnymea-common/types/vendor.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/vendors.cpp b/libnymea-common/types/vendors.cpp index 48f3d0c3..18df232d 100644 --- a/libnymea-common/types/vendors.cpp +++ b/libnymea-common/types/vendors.cpp @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/libnymea-common/types/vendors.h b/libnymea-common/types/vendors.h index 87f99957..6ab43700 100644 --- a/libnymea-common/types/vendors.h +++ b/libnymea-common/types/vendors.h @@ -2,7 +2,7 @@ * * * Copyright (C) 2017 Simon Stuerz * * * - * This file is part of nymea:app * + * This file is part of nymea:app * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public * diff --git a/nymea-app/ui/ConnectPage.qml b/nymea-app/ui/ConnectPage.qml index cdfc15d7..c1881875 100644 --- a/nymea-app/ui/ConnectPage.qml +++ b/nymea-app/ui/ConnectPage.qml @@ -173,6 +173,14 @@ Page { } contentItem: RowLayout { + + ColorIcon { + Layout.fillHeight: true + Layout.preferredWidth: height + name: model.type === DiscoveryDevice.DeviceTypeNetwork ? "../images/network-vpn.svg" : "../images/bluetooth.svg" + color: app.guhAccent + } + ColumnLayout { Layout.fillWidth: true Label { @@ -181,10 +189,11 @@ Page { elide: Text.ElideRight } Label { - text: model.hostAddress + text: model.type === DiscoveryDevice.DeviceTypeNetwork ? model.hostAddress : model.bluetoothAddress font.pixelSize: app.smallFont } } + ColorIcon { Layout.fillHeight: true Layout.preferredWidth: height @@ -193,12 +202,16 @@ Page { visible: hasSecurePort name: "../images/network-secure.svg" color: isTrusted ? app.guhAccent : keyColor - } } onClicked: { - Engine.connection.connect(discoveryDevice.toUrl(defaultPortConfigIndex)) + if (model.type === DiscoveryDevice.DeviceTypeNetwork) { + Engine.connection.connect(discoveryDevice.toUrl(defaultPortConfigIndex)) + } else if (model.type === DiscoveryDevice.DeviceTypeNetwork) { + Engine.connection.connect(discoveryDevice.toUrl(model.bluetoothAddress)) + } + pageStack.push(connectingPage) }