Add serial number to uart information
This commit is contained in:
parent
8225687369
commit
9381a5dcef
@ -51,6 +51,11 @@ bool ZigbeeNode::connected() const
|
||||
return m_connected;
|
||||
}
|
||||
|
||||
QUuid ZigbeeNode::networkUuid() const
|
||||
{
|
||||
return m_network->networkUuid();
|
||||
}
|
||||
|
||||
ZigbeeDeviceObject *ZigbeeNode::deviceObject() const
|
||||
{
|
||||
return m_deviceObject;
|
||||
|
||||
@ -57,6 +57,8 @@ public:
|
||||
State state() const;
|
||||
bool connected() const;
|
||||
|
||||
QUuid networkUuid() const;
|
||||
|
||||
ZigbeeDeviceObject *deviceObject() const;
|
||||
|
||||
quint16 shortAddress() const;
|
||||
|
||||
@ -52,14 +52,24 @@ void ZigbeeUartAdapter::setDescription(const QString &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
|
||||
@ -95,7 +105,10 @@ void ZigbeeUartAdapter::setBaudRate(qint32 baudRate)
|
||||
QDebug operator<<(QDebug debug, const ZigbeeUartAdapter &adapter)
|
||||
{
|
||||
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()) {
|
||||
debug.nospace() << "Suggested backend: " << adapter.zigbeeBackend();
|
||||
debug.nospace() << ", " << adapter.baudRate();
|
||||
|
||||
@ -44,8 +44,11 @@ public:
|
||||
QString description() const;
|
||||
void setDescription(const QString &description);
|
||||
|
||||
QString systemLocation() const;
|
||||
void setSystemLocation(const QString &systemLocation);
|
||||
QString serialPort() const;
|
||||
void setSerialPort(const QString &serialPort);
|
||||
|
||||
QString serialNumber() const;
|
||||
void setSerialNumber(const QString &serialNumber);
|
||||
|
||||
bool hardwareRecognized() const;
|
||||
void setHardwareRecognized(bool hardwareRecognized);
|
||||
@ -59,7 +62,8 @@ public:
|
||||
private:
|
||||
QString m_name;
|
||||
QString m_description;
|
||||
QString m_systemLocation;
|
||||
QString m_serialPort;
|
||||
QString m_serialNumber;
|
||||
|
||||
bool m_hardwareRecognized = false;
|
||||
Zigbee::ZigbeeBackendType m_zigbeeBackend = Zigbee::ZigbeeBackendTypeDeconz;
|
||||
|
||||
@ -182,14 +182,14 @@ bool ZigbeeUartAdapterMonitor::isValid() const
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocation)
|
||||
void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &serialPort)
|
||||
{
|
||||
foreach (const QSerialPortInfo &serialPortInfo, QSerialPortInfo::availablePorts()) {
|
||||
if (serialPortInfo.systemLocation() != systemLocation)
|
||||
if (serialPortInfo.systemLocation() != serialPort)
|
||||
continue;
|
||||
|
||||
if (m_availableAdapters.keys().contains(systemLocation)) {
|
||||
qCWarning(dcZigbeeAdapterMonitor()) << "The adapter" << systemLocation << "has already been added to the monitor.";
|
||||
if (m_availableAdapters.keys().contains(serialPort)) {
|
||||
qCWarning(dcZigbeeAdapterMonitor()) << "The adapter" << serialPort << "has already been added to the monitor.";
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -215,12 +215,14 @@ void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocatio
|
||||
adapter.setName(serialPortInfo.portName());
|
||||
}
|
||||
|
||||
|
||||
if (serialPortInfo.description().isEmpty()) {
|
||||
adapter.setDescription("Unknown");
|
||||
} else {
|
||||
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
|
||||
if (serialPortInfo.manufacturer().toLower().contains("dresden elektronik")) {
|
||||
@ -234,7 +236,7 @@ void ZigbeeUartAdapterMonitor::addAdapterInternally(const QString &systemLocatio
|
||||
}
|
||||
|
||||
qCDebug(dcZigbeeAdapterMonitor()) << "Added" << adapter;
|
||||
m_availableAdapters.insert(adapter.systemLocation(), adapter);
|
||||
m_availableAdapters.insert(adapter.serialPort(), adapter);
|
||||
emit adapterAdded(adapter);
|
||||
}
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ private:
|
||||
|
||||
QHash<QString, ZigbeeUartAdapter> m_availableAdapters;
|
||||
|
||||
void addAdapterInternally(const QString &systemLocation);
|
||||
void addAdapterInternally(const QString &serialPort);
|
||||
|
||||
signals:
|
||||
void adapterAdded(const ZigbeeUartAdapter &adapter);
|
||||
|
||||
Reference in New Issue
Block a user