Clean up source and dependencies and make build against libnymea-zigbee

This commit is contained in:
Simon Stürz 2020-10-28 09:45:38 +01:00
parent 228a4f9f9c
commit 0f0b903af8
7 changed files with 18 additions and 207 deletions

View File

@ -38,10 +38,10 @@ ZigbeeHandler::ZigbeeHandler(ZigbeeManager *zigbeeManager, QObject *parent) :
m_zigbeeManager(zigbeeManager)
{
registerEnum<ZigbeeNetwork::State>();
registerEnum<ZigbeeNetworkManager::BackendType>();
registerEnum<Zigbee::BackendType>();
registerObject<ZigbeeSerialPort>();
registerObject<ZigbeeSerialPort, ZigbeeSerialPortList>();
// registerObject<ZigbeeSerialPort>();
// registerObject<ZigbeeSerialPort, ZigbeeSerialPortList>();
QVariantMap params, returns;
QString description;
@ -60,7 +60,7 @@ ZigbeeHandler::ZigbeeHandler(ZigbeeManager *zigbeeManager, QObject *parent) :
returns.insert("configured", enumValueName(Bool));
returns.insert("serialPort", enumValueName(String));
returns.insert("baudRate", enumValueName(Uint));
returns.insert("backend", enumRef<ZigbeeNetworkManager::BackendType>());
returns.insert("backend", enumRef<Zigbee::BackendType>());
returns.insert("firmwareVersion", enumValueName(String));
returns.insert("networkIeeeeAddress", enumValueName(String));
returns.insert("networkPanId", enumValueName(Uint));
@ -70,10 +70,10 @@ ZigbeeHandler::ZigbeeHandler(ZigbeeManager *zigbeeManager, QObject *parent) :
registerMethod("GetNetworkStatus", description, params, returns);
// GetUartInterfaces
params.clear(); returns.clear();
description = "Get the available UART interfaces in order to set up the zigbee network on the approriate serial interface.";
returns.insert("uartInterfaces", objectRef<ZigbeeSerialPortList>());
registerMethod("GetUartInterfaces", description, params, returns);
// params.clear(); returns.clear();
// description = "Get the available UART interfaces in order to set up the zigbee network on the approriate serial interface.";
// returns.insert("uartInterfaces", objectRef<ZigbeeSerialPortList>());
// registerMethod("GetUartInterfaces", description, params, returns);
// GetNetworkStatus
// NetworkStatusChanged
@ -125,11 +125,11 @@ JsonReply *ZigbeeHandler::GetUartInterfaces(const QVariantMap &params)
{
Q_UNUSED(params)
QVariantMap ret;
QVariantList portList;
foreach (const ZigbeeSerialPort &serialPort, m_zigbeeManager->availablePorts()) {
portList << pack(serialPort);
}
ret.insert("uartInterfaces", portList);
// QVariantList portList;
// foreach (const ZigbeeSerialPort &serialPort, m_zigbeeManager->availablePorts()) {
// portList << pack(serialPort);
// }
// ret.insert("uartInterfaces", portList);
return createReply(ret);
}

View File

@ -130,8 +130,7 @@ HEADERS += nymeacore.h \
cloud/cloudtransport.h \
debugreportgenerator.h \
platform/platform.h \ \
zigbee/zigbeemanager.h \
zigbee/zigbeeserialport.h
zigbee/zigbeemanager.h
SOURCES += nymeacore.cpp \
@ -217,8 +216,7 @@ SOURCES += nymeacore.cpp \
cloud/cloudtransport.cpp \
debugreportgenerator.cpp \
platform/platform.cpp \
zigbee/zigbeemanager.cpp \
zigbee/zigbeeserialport.cpp
zigbee/zigbeemanager.cpp
versionAtLeast(QT_VERSION, 5.12.0) {

View File

@ -56,34 +56,7 @@ ZigbeeNetwork *ZigbeeManager::zigbeeNetwork() const
return m_zigbeeNetwork;
}
ZigbeeSerialPortList ZigbeeManager::availablePorts()
{
ZigbeeSerialPortList ports;
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) {
qCDebug(dcZigbee()) << "Found serial port" << serialPortInfo.portName();
qCDebug(dcZigbee()) << " Description:" << serialPortInfo.description();
qCDebug(dcZigbee()) << " System location:" << serialPortInfo.systemLocation();
qCDebug(dcZigbee()) << " Manufacturer:" << serialPortInfo.manufacturer();
qCDebug(dcZigbee()) << " Serialnumber:" << serialPortInfo.serialNumber();
if (serialPortInfo.hasProductIdentifier()) {
qCDebug(dcZigbee()) << " Product identifier:" << serialPortInfo.productIdentifier();
}
if (serialPortInfo.hasVendorIdentifier()) {
qCDebug(dcZigbee()) << " Vendor identifier:" << serialPortInfo.vendorIdentifier();
}
ZigbeeSerialPort port;
port.setName(serialPortInfo.portName());
port.setDescription(serialPortInfo.description());
port.setSystemLocation(serialPortInfo.systemLocation());
ports.append(port);
}
return ports;
}
void ZigbeeManager::createZigbeeNetwork(const QString &serialPort, qint32 baudrate, ZigbeeNetworkManager::BackendType backend)
void ZigbeeManager::createZigbeeNetwork(const QString &serialPort, qint32 baudrate, Zigbee::BackendType backend)
{
if (m_zigbeeNetwork) {
delete m_zigbeeNetwork;

View File

@ -35,8 +35,6 @@
#include <zigbeenetworkmanager.h>
#include "zigbeeserialport.h"
namespace nymeaserver {
class ZigbeeManager : public QObject
@ -50,9 +48,7 @@ public:
ZigbeeNetwork *zigbeeNetwork() const;
ZigbeeSerialPortList availablePorts();
void createZigbeeNetwork(const QString &serialPort, qint32 baudrate, ZigbeeNetworkManager::BackendType backend);
void createZigbeeNetwork(const QString &serialPort, qint32 baudrate, Zigbee::BackendType backend);
private:
ZigbeeNetwork *m_zigbeeNetwork = nullptr;

View File

@ -1,80 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, GNU version 3. This project 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.
*
* You should have received a copy of the GNU General Public License along with
* this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "zigbeeserialport.h"
namespace nymeaserver {
ZigbeeSerialPort::ZigbeeSerialPort()
{
}
QString ZigbeeSerialPort::name() const
{
return m_name;
}
void ZigbeeSerialPort::setName(const QString &name)
{
m_name = name;
}
QString ZigbeeSerialPort::description() const
{
return m_description;
}
void ZigbeeSerialPort::setDescription(const QString &description)
{
m_description = description;
}
QString ZigbeeSerialPort::systemLocation() const
{
return m_systemLocation;
}
void ZigbeeSerialPort::setSystemLocation(const QString &systemLocation)
{
m_systemLocation = systemLocation;
}
QVariant ZigbeeSerialPortList::get(int index) const
{
return QVariant::fromValue(at(index));
}
void ZigbeeSerialPortList::put(const QVariant &variant)
{
append(variant.value<ZigbeeSerialPort>());
}
}

View File

@ -1,77 +0,0 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
* This project including source code and documentation is protected by
* copyright law, and remains the property of nymea GmbH. All rights, including
* reproduction, publication, editing and translation, are reserved. The use of
* this project is subject to the terms of a license agreement to be concluded
* with nymea GmbH in accordance with the terms of use of nymea GmbH, available
* under https://nymea.io/license
*
* GNU General Public License Usage
* Alternatively, this project may be redistributed and/or modified under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, GNU version 3. This project 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.
*
* You should have received a copy of the GNU General Public License along with
* this project. If not, see <https://www.gnu.org/licenses/>.
*
* For any further details and any questions please contact us under
* contact@nymea.io or see our FAQ/Licensing Information on
* https://nymea.io/license/faq
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#ifndef ZIGBEESERIALPORT_H
#define ZIGBEESERIALPORT_H
#include <QObject>
#include <QVariant>
namespace nymeaserver {
class ZigbeeSerialPort
{
Q_GADGET
Q_PROPERTY(QString name READ name)
Q_PROPERTY(QString description READ description)
Q_PROPERTY(QString systemLocation READ systemLocation)
public:
ZigbeeSerialPort();
QString name() const;
void setName(const QString &name);
QString description() const;
void setDescription(const QString &description);
QString systemLocation() const;
void setSystemLocation(const QString &systemLocation);
private:
QString m_name;
QString m_description;
QString m_systemLocation;
};
class ZigbeeSerialPortList: public QList<ZigbeeSerialPort>
{
Q_GADGET
Q_PROPERTY(int count READ count)
public:
Q_INVOKABLE QVariant get(int index) const;
Q_INVOKABLE void put(const QVariant &variant);
};
}
Q_DECLARE_METATYPE(nymeaserver::ZigbeeSerialPort)
Q_DECLARE_METATYPE(nymeaserver::ZigbeeSerialPortList)
#endif // ZIGBEESERIALPORT_H

View File

@ -76,6 +76,7 @@ NYMEA_LOGGING_CATEGORY(dcBluetoothServerTraffic, "BluetoothServerTraffic")
NYMEA_LOGGING_CATEGORY(dcMqtt, "Mqtt")
NYMEA_LOGGING_CATEGORY(dcTranslations, "Translations")
NYMEA_LOGGING_CATEGORY(dcI2C, "I2C")
NYMEA_LOGGING_CATEGORY(dcZigbeeHardwareResource, "ZigbeeHardwareResource")
static QFile s_logFile;