Add serial number to uart information

This commit is contained in:
Simon Stürz 2020-11-05 15:36:23 +01:00
parent 8225687369
commit 9381a5dcef
6 changed files with 41 additions and 15 deletions

View File

@ -51,6 +51,11 @@ bool ZigbeeNode::connected() const
return m_connected; return m_connected;
} }
QUuid ZigbeeNode::networkUuid() const
{
return m_network->networkUuid();
}
ZigbeeDeviceObject *ZigbeeNode::deviceObject() const ZigbeeDeviceObject *ZigbeeNode::deviceObject() const
{ {
return m_deviceObject; return m_deviceObject;

View File

@ -57,6 +57,8 @@ public:
State state() const; State state() const;
bool connected() const; bool connected() const;
QUuid networkUuid() const;
ZigbeeDeviceObject *deviceObject() const; ZigbeeDeviceObject *deviceObject() const;
quint16 shortAddress() const; quint16 shortAddress() const;

View File

@ -52,14 +52,24 @@ void ZigbeeUartAdapter::setDescription(const QString &description)
m_description = description; m_description = description;
} }
QString ZigbeeUartAdapter::systemLocation() const QString ZigbeeUartAdapter::serialPort() const
{ {
return m_systemLocation; return m_serialPort;
} }
void ZigbeeUartAdapter::setSystemLocation(const QString &systemLocation) void ZigbeeUartAdapter::setSerialPort(const QString &serialPort)
{ {
m_systemLocation = systemLocation; m_serialPort = serialPort;
}
QString ZigbeeUartAdapter::serialNumber() const
{
return m_serialNumber;
}
void ZigbeeUartAdapter::setSerialNumber(const QString &serialNumber)
{
m_serialNumber = serialNumber;
} }
bool ZigbeeUartAdapter::hardwareRecognized() const bool ZigbeeUartAdapter::hardwareRecognized() const
@ -95,7 +105,10 @@ void ZigbeeUartAdapter::setBaudRate(qint32 baudRate)
QDebug operator<<(QDebug debug, const ZigbeeUartAdapter &adapter) QDebug operator<<(QDebug debug, const ZigbeeUartAdapter &adapter)
{ {
debug.nospace() << "ZigbeeUartAdapter(" << adapter.name() << " - " << adapter.description(); debug.nospace() << "ZigbeeUartAdapter(" << adapter.name() << " - " << adapter.description();
debug.nospace() << ", " << adapter.systemLocation(); debug.nospace() << ", " << adapter.serialPort();
if (!adapter.serialNumber().isEmpty()) {
debug.nospace() << ", " << adapter.serialNumber();
}
if (adapter.hardwareRecognized()) { if (adapter.hardwareRecognized()) {
debug.nospace() << "Suggested backend: " << adapter.zigbeeBackend(); debug.nospace() << "Suggested backend: " << adapter.zigbeeBackend();
debug.nospace() << ", " << adapter.baudRate(); debug.nospace() << ", " << adapter.baudRate();

View File

@ -44,8 +44,11 @@ public:
QString description() const; QString description() const;
void setDescription(const QString &description); void setDescription(const QString &description);
QString systemLocation() const; QString serialPort() const;
void setSystemLocation(const QString &systemLocation); void setSerialPort(const QString &serialPort);
QString serialNumber() const;
void setSerialNumber(const QString &serialNumber);
bool hardwareRecognized() const; bool hardwareRecognized() const;
void setHardwareRecognized(bool hardwareRecognized); void setHardwareRecognized(bool hardwareRecognized);
@ -59,7 +62,8 @@ public:
private: private:
QString m_name; QString m_name;
QString m_description; QString m_description;
QString m_systemLocation; QString m_serialPort;
QString m_serialNumber;
bool m_hardwareRecognized = false; bool m_hardwareRecognized = false;
Zigbee::ZigbeeBackendType m_zigbeeBackend = Zigbee::ZigbeeBackendTypeDeconz; Zigbee::ZigbeeBackendType m_zigbeeBackend = Zigbee::ZigbeeBackendTypeDeconz;

View File

@ -182,14 +182,14 @@ bool ZigbeeUartAdapterMonitor::isValid() const
return m_isValid; return m_isValid;
} }
void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocation) void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &serialPort)
{ {
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) { foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) {
if (serialPortInfo.systemLocation() != systemLocation) if (serialPortInfo.systemLocation() != serialPort)
continue; continue;
if (m_availableAdapters.keys().contains(systemLocation)) { if (m_availableAdapters.keys().contains(serialPort)) {
qCWarning(dcZigbeeAdapterMonitor()) << "The adapter" << systemLocation << "has already been added to the monitor."; qCWarning(dcZigbeeAdapterMonitor()) << "The adapter" << serialPort << "has already been added to the monitor.";
continue; continue;
} }
@ -215,12 +215,14 @@ void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocatio
adapter.setName(serialPortInfo.portName()); adapter.setName(serialPortInfo.portName());
} }
if (serialPortInfo.description().isEmpty()) { if (serialPortInfo.description().isEmpty()) {
adapter.setDescription("Unknown"); adapter.setDescription("Unknown");
} else { } else {
adapter.setDescription(serialPortInfo.description()); adapter.setDescription(serialPortInfo.description());
} }
adapter.setSystemLocation(serialPortInfo.systemLocation()); adapter.setSerialPort(serialPortInfo.systemLocation());
adapter.setSerialNumber(serialPortInfo.serialNumber());
// Check if we recognize this adapter from USB information // Check if we recognize this adapter from USB information
if (serialPortInfo.manufacturer().toLower().contains("dresden elektronik")) { if (serialPortInfo.manufacturer().toLower().contains("dresden elektronik")) {
@ -234,7 +236,7 @@ void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocatio
} }
qCDebug(dcZigbeeAdapterMonitor()) << "Added" << adapter; qCDebug(dcZigbeeAdapterMonitor()) << "Added" << adapter;
m_availableAdapters.insert(adapter.systemLocation(), adapter); m_availableAdapters.insert(adapter.serialPort(), adapter);
emit adapterAdded(adapter); emit adapterAdded(adapter);
} }

View File

@ -53,7 +53,7 @@ private:
QHash<QString, ZigbeeUartAdapter> m_availableAdapters; QHash<QString, ZigbeeUartAdapter> m_availableAdapters;
void addAdapterInternally(const QString &systemLocation); void addAdapterInternally(const QString &serialPort);
signals: signals:
void adapterAdded(const ZigbeeUartAdapter &adapter); void adapterAdded(const ZigbeeUartAdapter &adapter);